BASIC4MCU | 질문게시판 | 코드질문입니다 ㅠㅠ 도와주세요 ㅠㅠ
페이지 정보
작성자 도와주십쇼 작성일2019-12-20 06:12 조회2,956회 댓글0건본문
아두이노 뉴비입니다.
스위치를 누른 순서에 따라 부저의 소리가 각각 다르게 내는 코드를 짜고 있습니다.
어디가 문제인지 어떻게 해야할지 몰라 급히 가입하여 질문합니다 ㅠㅠ 도와주세요 ㅠㅠㅠ
int piezohi = 9;//초록
int piezobye = 8;//노랑
int numToneshi = 4;
int toneshi[] = {261, 330, 392, 523};
int numTonesbye = 4;
int tonesbye[] = {523, 392, 330, 261};
int ButtonO = 1;//주황
int ButtonP = 2;//보라
int count = 0;
void setup() {
pinMode(piezohi, OUTPUT);
pinMode(piezobye, OUTPUT);
pinMode(ButtonO, INPUT);
pinMode(ButtonP, INPUT);
Serial.begin(9600);
}
void loop() {
while (ButtonO == LOW);
while (ButtonP == LOW);
count++;
while (ButtonP == LOW);
while (ButtonO == LOW);
count--;
if (count == 1) {
for (int i = 0; i < numToneshi; i++) {
tone(piezohi, toneshi[i]);
Serial.println("hi");
delay(300);
}
} else {
for (int i = 0; i < numTonesbye; i++) {
tone(piezobye, tonesbye[i]);
Serial.println("bye");
delay(300);
}
}
noTone(piezohi);
noTone(piezobye);
}
댓글 0
조회수 2,956등록된 댓글이 없습니다.