04 BUZZER 2 (MI PRIMERA MELODÍA)

Código del programa :


//HOLA SOMOS QIAN YAN Y SANDRA DE 3ºC
//CONECTAR EL ALTAVOZ AL PIN 12
#define PINBUZZER 5

// Nº de notas negras en un minuto
#define TEMPO 120

// Frecuencias de las notas
// musicales de una escala
#define Do 262
#define Re 294
#define Mi 320
#define Fa 349
#define Sol 392
#define La 440
#define Si 494
#define Do_alto 523

// Duraciones de las notas
// musicasles en milisegundos
#define NEGRA 60000/TEMPO
#define REDONDA          NEGRA *4
#define BLANCA           NEGRA *2
#define CORCHEA          NEGRA /2
#define SEMICORCHEA      NEGRA /4

void setup()
{
    tone (PINBUZZER,Do_alto,CORCHEA) ;
    delay (CORCHEA*1.3) ;
 
    //Para diferenciar entre las notas
    //esperamos un 30 %
    tone(PINBUZZER,Sol,SEMICORCHEA) ;
    delay(SEMICORCHEA*1.3) ;
    tone(PINBUZZER,Sol,SEMICORCHEA) ;
    delay(SEMICORCHEA*1.3) ;
    tone(PINBUZZER,La,CORCHEA) ;
    delay(CORCHEA*1.3);
    tone(PINBUZZER,Sol,CORCHEA) ;
    delay(CORCHEA*1.3) ;
    noTone(PINBUZZER) ;    //Silencio
    delay(CORCHEA);
    tone(PINBUZZER,Si,CORCHEA) ;
    delay(CORCHEA*1.3) ;
    tone(PINBUZZER,Do_alto,CORCHEA) ;
    delay(CORCHEA*1.3) ;
 
}
void loop()
{
     //No queremos repetir la melodia.
}
 

Foto y vídeo :





Comentarios

Entradas populares de este blog

LOS CUATRO TIEMPOS DE UN MOTOR DE EXPLOSIÓN

010 CUANDO YA NO ESTÉ : Energía y transporte con Tony Seba