Advertisement
ostapdontstop

gavno arduino

Jul 24th, 2018
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. #define PIN_LED1 7
  2. #define SoundPin 9
  3. int i = 1;
  4. //const int SoundPin = 9; // Пин подключения пьезоизлучателя – 9 дискретный
  5. int DelaySound = 500; // Пауза 1 секунда
  6. void setup() {
  7. pinMode(PIN_LED1, OUTPUT);
  8. attachInterrupt(1, myEventListener, HIGH);
  9. }
  10.  
  11. void loop() {
  12. if(i == 0) {
  13. tone(SoundPin, 262); // ДО
  14. delay(DelaySound); // Пауза 1 секунда (1000 миллисекунд – значение переменной DelaySound ) – длительность воспроизведения сигнала
  15. tone(SoundPin, 294); //РЕ
  16. delay(DelaySound);
  17. tone(SoundPin, 329);//МИ
  18. delay(DelaySound);
  19. tone(SoundPin, 349);//ФА
  20. delay(DelaySound);
  21. tone(SoundPin, 392);//СОЛЬ
  22. delay(DelaySound);
  23. tone(SoundPin, 440);//ЛЯ
  24. delay(DelaySound);
  25. tone(SoundPin, 494);//СИ
  26. delay(DelaySound);
  27. noTone(9); // Выключаем звук
  28.  
  29. }
  30. if(i == 1) {
  31. tone(SoundPin, 494);//СИ
  32. delay(DelaySound);
  33. tone(SoundPin, 440);//ЛЯ
  34. delay(DelaySound);
  35. tone(SoundPin, 392);//СОЛЬ
  36. delay(DelaySound);
  37. tone(SoundPin, 349);//ФА
  38. delay(DelaySound);
  39. tone(SoundPin, 329);//МИ
  40. delay(DelaySound);
  41. tone(SoundPin, 294); //РЕ
  42. delay(DelaySound);
  43. tone(SoundPin, 262); // ДО
  44. delay(DelaySound);
  45. noTone(9);
  46. }
  47. if(digitalRead(4) == HIGH){
  48. i = 0;
  49. }
  50. }
  51.  
  52. void myEventListener() {
  53. // Выполняем другие действия, например, включаем или выключаем светодиод
  54. digitalWrite(PIN_LED1, HIGH);
  55. for(int i = 0; i < 500; i++){
  56. delay(1);
  57. }
  58. digitalWrite(PIN_LED1, LOW);
  59. for(int i = 0; i < 500; i++){
  60. delay(1);
  61. }
  62. digitalWrite(PIN_LED1, HIGH);
  63. for(int i = 0; i < 500; i++){
  64. delay(1);
  65. }
  66. digitalWrite(PIN_LED1, LOW);
  67. for(int i = 0; i < 500; i++){
  68. delay(1);
  69. }
  70. }
  71.  
  72.  
  73.  
  74. здесь нет в ифе i = 0
  75. if(i == 1) {
  76. tone(SoundPin, 494);//СИ
  77. delay(DelaySound);
  78. tone(SoundPin, 440);//ЛЯ
  79. delay(DelaySound);
  80. tone(SoundPin, 392);//СОЛЬ
  81. delay(DelaySound);
  82. tone(SoundPin, 349);//ФА
  83. delay(DelaySound);
  84. tone(SoundPin, 329);//МИ
  85. delay(DelaySound);
  86. tone(SoundPin, 294); //РЕ
  87. delay(DelaySound);
  88. tone(SoundPin, 262); // ДО
  89. delay(DelaySound);
  90. noTone(9);
  91. } (ред.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement