Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. const int SoundPin = 9;
  2. int DelaySound = 500;
  3. void setup() {
  4. attachInterrupt(0, Sound, HIGH);
  5. }
  6.  
  7. void loop() {
  8. if(digitalRead(2) == LOW){
  9. digitalWrite(7, HIGH);
  10. delay(500);
  11. digitalWrite(7, LOW);
  12. delay(250);
  13. }
  14. if(digitalRead(2) == HIGH){
  15. Sound();
  16. }
  17. }
  18. void Sound(){
  19. tone(SoundPin, 262); // ДО
  20. delay(DelaySound);
  21. tone(SoundPin, 294); //РЕ
  22. delay(DelaySound);
  23. tone(SoundPin, 329);//МИ
  24. delay(DelaySound);
  25. tone(SoundPin, 349);//ФА
  26. delay(DelaySound);
  27. tone(SoundPin, 392);//СОЛЬ
  28. delay(DelaySound);
  29. tone(SoundPin, 440);//ЛЯ
  30. delay(DelaySound);
  31. tone(SoundPin, 494);//СИ
  32. delay(DelaySound);
  33. noTone(9);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement