Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buzzer = 11;
- const int button = 6;
- bool isPressed;
- // Hertz of each note
- int G = 196;
- int B = 235; // Yfesi
- int C = 262;
- int D = 276; // Yfesi
- // Times
- int miso = 1200;
- int tetarto = 600;
- int ogdoo = 300;
- int pause = 50;
- void setup()
- {
- Serial.begin(9600);
- pinMode(button, INPUT);
- }
- void loop()
- {
- isPressed = digitalRead(button);
- if(isPressed == true){
- Serial.println("Button is pressed. Music is ready");
- // 1st part
- tone(buzzer, G);
- delay(tetarto);
- tone(buzzer, B);
- delay(tetarto);
- tone(buzzer, C);
- delay(1.5 * tetarto);
- // 2nd part
- tone(buzzer, G);
- delay(tetarto);
- tone(buzzer, B);
- delay(tetarto);
- tone(buzzer, D);
- delay(ogdoo);
- tone(buzzer, C);
- delay(miso);
- // 3rd part
- tone(buzzer, G);
- delay(tetarto);
- tone(buzzer, B);
- delay(tetarto);
- tone(buzzer, C);
- delay(1.5 * tetarto);
- // 4th part
- tone(buzzer, B);
- delay(tetarto);
- tone(buzzer, G);
- delay(miso);
- noTone(buzzer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement