int sheet[]={0,261,294,329,349,392,440,493,523};
#define BUTTON 2 #define BUZZER 8
int melody[] = { 5,3,3,0,4,2,2,0,1,2,3,4,5,5,5,0 };
int noteDurations[] = { 10, 10, 10, 10, 10, 10, 10, 10, 10,10, 10, 10, 10, 10, 10, 10 };
int pin; int ledArrayHigh; int ledArrayLow; boolean mode = false; boolean buttonPressed = false;
void setup() { delay(1000); pinMode(BUTTON, INPUT_PULLUP); for (pin = 3; pin < 14; pin++) { pinMode(pin, OUTPUT); }
for (int thisNote = 0; thisNote < 16; thisNote++) { int noteDuration = 1000 / noteDurations[thisNote]; tone(BUZZER, sheet[melody[thisNote]], noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(BUZZER); } }
|
沒有留言:
張貼留言