Notice
Recent Posts
Recent Comments
Creative Code
12_timer1_piezo 본문
#include <TimerOne.h>
const int BUZZER = 10;
const int melody[] = {262,294,330,349,393,440,494,523,};
void setup() {
// put your setup code here, to run once:
Timer1.initialize();
Timer1.pwm(BUZZER,0);
Timer1.setPwmDuty(BUZZER,100);
for (int note = 0; note<8; note++) {
Timer1.setPeriod(1000000/melody[note]);
delay(500);
}
Timer1.setPwmDuty(BUZZER,0);
}
void loop() {
// put your main code here, to run repeatedly:
}
'Arduino(C,C++)' 카테고리의 다른 글
14_FND (0) | 2023.08.14 |
---|---|
13_PCINT_ultrasonic(timer1함수를 이용한 거리측정) (0) | 2023.08.14 |
11_timer1_led (0) | 2023.08.14 |
10_ultrasonic(초음파 거리재기) (0) | 2023.08.11 |
09_tone (0) | 2023.08.11 |