Arduino/elegoo-kit-lessons/Lesson 7 Passive Buzzer/passive_buzzer/passive_buzzer.ino
2022-02-20 16:18:02 -05:00

27 lines
527 B
C++
Executable File

//www.elegoo.com
//2016.12.08
#include "pitches.h"
// notes in the melody:
int melody[] = {
NOTE_C5, NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6};
int duration = 500; // 500 miliseconds
void setup() {
}
void loop() {
for (int thisNote = 0; thisNote < 8; thisNote++) {
// pin8 output the voice, every scale is 0.5 sencond
tone(8, melody[thisNote], duration);
// Output the voice after several minutes
delay(1000);
}
// restart after two seconds
delay(2000);
}