Работает только 4 кнопки и только по одному разу.
Сделать нужно ближайшие два дня.
Сделать нужно ближайшие два дня.
C++:
#define NOTE_A 262
#define NOTE_B 294
#define NOTE_C 330
#define NOTE_D 392
#define NOTE_E 493
const int SPEAKER=13;
const int BUT_A=2;
const int BUT_B=3;
const int BUT_C=4;
const int BUT_D=5;
const int BUT_E=7;
void setup() {
pinMode(13, OUTPUT);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
}
void loop() {
while (digitalRead(BUT_A)==1);
tone(SPEAKER, NOTE_A, 30);
while (digitalRead(BUT_B)==1);
tone(SPEAKER, NOTE_B, 30);
while (digitalRead(BUT_C)==1);
tone(SPEAKER, NOTE_C, 30);
while (digitalRead(BUT_D)==1);
tone(SPEAKER, NOTE_D, 30);
while (digitalRead(BUT_E)==1);
tone(SPEAKER, NOTE_E, 30);
noTone(SPEAKER);
}
Вложения
-
167.6 KB Просмотры: 18