아두이노_우노
아두이노 우노 - 버튼 풀다운 도레미
아스키의 공부방
2019. 11. 13. 22:47
728x90
반응형


#include <pitches.h>
#define DURATION 10
int notes[] = { NOTE_E4, NOTE_D4, NOTE_C4 };
int btns[] = { 8, 9, 10 };
int speaker = 4;
long b_state;
void setup() {
// put your setup code here, to run once:
for(int i = 0; i < 3; i++) {
pinMode(btns[i], INPUT);
}
pinMode(speaker, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int state = 0;
for (int i=0; i<3; i++) {
boolean b_state = digitalRead(btns[i]);
if(b_state)
tone(speaker, notes[i], 1000);
}
}
728x90
반응형