I am woriking on a project where I need to contoll a buzzer to play music without using the delay(); command. I am using mills to do this. I have two libraries, one for the diffrent notes, and one for all the songs. When I upload and run the program it compiles but no sound is made. I have quadruple checked my hardware so I am shure this must be a software issue. Can somebody tell me what I have done wrong?
const int buzzerPin = 3;
int timeMS = 0;
int bcMusic = 0;
void setup() {
pinMode(buzzerPin, OUTPUT);
}
int thisNote = 0;
bool cooldown = 0;
int timerMax = 0;
void playMelody(int melody[], int ND[]) {
if ((thisNote < (sizeof(melody))) && (cooldown == 0)) {
cooldown = 1;
int noteDuration = ND[thisNote] * 500;
tone(buzzerPin, melody[thisNote], 500);
timerMax = (500 * 1.30) + timeMS;
thisNote++;
}
if (timeMS >= timerMax) {
cooldown = 0;
if (thisNote > (sizeof(melody))){thisNote = 0;}
}
}
void loop() {
// put your main code here, to run repeatedly:
timeMS = millis();
bcMusic = 1;
playMelody(menueTheme, menueThemeND);
//menueTheme & menueThemeND (ND= note durations) are int lists defined in a seperate document
}
//