Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

sbit LCD_RS at RD4_bit; //Entradas desde el LCD al Microcontrolador

sbit LCD_EN at RD5_bit;


sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;

sbit LCD_RS_Direction at TRISD4_bit;


sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
// Se crean los textos que se van a usar en el resto de programación

char txt1[] = "PICazo";


char txt2[] = "Domingo Comin";
char txt3[] = "3ero";
char txt4[] = "Año lectivo";
char txt5[] = "2022-2023";
char txt6[] = "Jose";
char txt7[] = "Alvarez";
char txt10[] = "Mecatronica A";
char txt11[] = "Generador de";
char txt12[] = "Megaman final";
char txt13[] = "Mozart 40";
char txt14[] = "Tema";
char txt15[] = "tonos musicales";

#define Boton1 PORTA.RA0 //declaración de RA0 Y RA1


#define Boton2 PORTA.RA1 //son las entradas para los botones
void main(){
TRISA=0b00000011;
PORTA=0;
ANSEL=0; // Configure AN pins as digital I/O
ANSELH=0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;

//Presentación del grupo, integrantes,


//nombre de la práctica, año lectivo y curso

Lcd_Init(); // Iniciamos el LCD

Lcd_Cmd(_LCD_CLEAR); // Limpiamos el display


Lcd_Cmd(_LCD_CURSOR_OFF); // Apagamos el cursor
Lcd_Out(1,6,txt1);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1,2,txt2); // Write text in second row


Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Out(1,1,txt3);
Lcd_Out(2,1,txt10);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,txt4);
Lcd_Out(2,1,txt5);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1,1,txt6);
Lcd_Out(2,1,txt7);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1,1,txt11);
Lcd_Out(2,1,txt15);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);

//Primera melodía: Megamanx3 Theme final


Sound_Init(&PORTC,0);
while(1) { // Endless loop
if (Boton1==1){
Lcd_Init();

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(2,1,txt12); // Se muestra nombre de la melodía

//Suena melodia

Sound_play(988,37); //FA
Sound_play(1245,429); //LA
Sound_play(1319,214); //FA
Sound_play(1481,215); //MI
Sound_play(1245,428); //FA
Sound_play(1109,215); //LA
Sound_play(988,215); //FA
Sound_play(1481,429); //RE
Sound_play(1245,1071); //RE
Sound_play(1865,213); //FA
Sound_play(1480,1600); //RE
Sound_play(1865,214); //DO
Sound_play(1976,1286); //RE
Sound_play(1480,215); //LA
Sound_play(1319,213); //SOL
Sound_play(1245,215); //RE
Sound_play(1319,213); //LA
Sound_play(1245,214); //SOL
Sound_play(1319,429); //FA
Sound_play(1245,214); //RE
Lcd_Cmd(_LCD_CLEAR); //limpiamos el display
}
//Segunda melodía: Megamanx final theme
if(Boton2 ==1){
Lcd_Init();

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,txt13);

//Suena segunda melodía Mozart


Sound_play(1241,42); //FA
delay_ms(100);
Sound_play(1171,41); //LA
delay_ms(100);
Sound_play(1175,96); //FA
delay_ms(100);
Sound_play(1173,87); //MI
delay_ms(100);
Sound_play(1242,40); //FA
delay_ms(100);
Sound_play(1169,41); //LA
delay_ms(100);
Sound_play(1175,145); //FA
Sound_play(1161,41);
delay_ms(100);
Sound_play(1241,40); //RE
delay_ms(100);
Sound_play(1171,41); //RE
delay_ms(100);
Sound_play(1175,95); //FA
delay_ms(100);
Sound_play(1865,49); //RE
Sound_play(1865,56);
Sound_play(1865,55);
delay_ms(386);
Sound_play(1862,41);
delay_ms(100);
Sound_play(1755,41);
delay_ms(100);
Sound_play(1881,185);
delay_ms(100);
Sound_play(1564,41);
delay_ms(100);
Sound_play(1389,42);
delay_ms(100);
Sound_play(1245,140);
Sound_play(1240,43);
delay_ms(100);
Sound_play(1242,49);
delay_ms(100);
Sound_play(1169,41);
delay_ms(100);
Sound_play(1171,41); //LA
delay_ms(100);
Sound_play(1171,41); //LA

Lcd_Cmd(_LCD_CLEAR); //limpiamos el display


}
}
}

You might also like