int times = 150;
int times2 = 75;
int times3 = 133;
void setup() {
// put your setup code here, to run once:
pinMode(9,INPUT);
pinMode(LED_BUILTIN,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = digitalRead(9);
if (sensorValue == HIGH){
digitalWrite(LED_BUILTIN,HIGH);
// Get ready for... LA CUCARACHA
tone(8,261,times2); //First part
delay(times);
tone(8,261,times2);
delay(times);
tone(8,261,times2*1.5);
delay(times);
tone(8,349,times2*2);
delay(times*1.5);
tone(8,440,times2);
delay(times);
tone(8,261,times2);
delay(times);
tone(8,261,times2);
delay(times);
tone(8,261,times2);
delay(times);
tone(8,349,times2*2);
delay(times*1.5);
tone(8,440,times2);
delay(times*2);
tone(8,349,times2); //Second part
delay(times3);
tone(8,349,times2);
delay(times3);
tone(8,329,times2);
delay(times3);
tone(8,329,times2);
delay(times3);
tone(8,293,times2);
delay(times3);
tone(8,293,times2);
delay(times3);
tone(8,261,times2*2);
delay(times*3);
}else{
digitalWrite(LED_BUILTIN,LOW);
}
delay(10);
}
Comments