My kit was acting weird/I didn’t know what I was doing so I wired the speaker to the bread board(?) to get it to play. There was a tutorial online that helped me write a song, and I did part of the James Bond theme.
#include “pitches.h”
//array of notes
int melody[] = {
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,0
};
int noteDurations[] = {
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,1
};
int pace = 1450;
void setup() {
for (int Note = 0; Note <54; Note++) {
int duration = pace/noteDurations[Note];
tone(8, melody[Note],duration);
delay(duration*1.2);
}
}
void loop() {
}