I am trying to make two buzzers go at the same time with different notes, while having LED pins. The attached is the test code I've created, but I can't seem to make them play at the same time. It only plays one buzzer at a time. Individually, it recognizes and plays both buzzers, but not together.
CODE:
const int c = 261;
const int d = 293;
const int e = 329;
const int f = 349;
const int g = 392;
const int a = 440;
const int b = 493;
const int cH = 523;
const int dH = 587;
const int eH = 659;
const int buzzerPin = 8;
const int buzzerPin2 = 5;
const int ledPin1 = 12;
const int ledPin2 = 13;
int counter = 0;
void beep(int note, int duration)
{
//Play tone on buzzerPin
tone(buzzerPin, note, duration);
//Play different LED depending on value of 'counter'
if(counter % 2 == 0);
}
void beep2(int note2, int duration2)
{
//Play tone on buzzerPin
tone(buzzerPin2, note2, duration2);
//Play different LED depending on value of 'counter'
if(counter % 2 == 0);
}
void setup()
{
//Setup pin modes
pinMode(buzzerPin, OUTPUT);
pinMode(buzzerPin2, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop()
{
beep(c, 250), beep2(e, 250);
delay(500);
beep(d, 250), beep2(f, 250);
delay(500);
beep(e, 250), beep2(g, 250);
delay(500);
beep(f, 250), beep2(a, 250);
delay(500);
beep(g, 250), beep2(b, 250);
delay(500);
beep(a, 250), beep2(cH, 250);
delay(500);
beep(b, 250), beep2(dH, 250);
delay(500);
beep(cH, 250), beep2(eH, 250);
delay(500);
beep2(b, 250);
delay(500);
beep2(a, 250);
delay(500);
beep2(f, 250);
delay(500);
beep2(e, 250);
delay(500);
beep2(d, 250);
delay(500);
beep2(c, 250);
delay(500);
}