Simultaneous two Speaker Output


hello,

i wanted know how able output tones 2 speakers, playing different notes simultaneously.

as of can play tones out of 2 speakers @ different times. how make them simultaneous.

this code have

code: [select]

void setup() {
 pinmode (4, output);
}

void fourfunction() {
   buzz(4, 1567, 250);
   buzz(4, 1479, 250);  
   buzz(4, 1318, 250);  
   buzz(4, 1318, 250);  
   buzz(4, 1479, 750);
   
   delay(500);
}

void loop() {
 fourfunction();
}



void buzz(int targetpin, long frequency, long length) {
   long delayvalue = 1000000/frequency/2;
   long numcycles = frequency * length/ 1000;
   for (long i=0; < numcycles; i++){
       digitalwrite(targetpin,high);
       delaymicroseconds(delayvalue);
       digitalwrite(targetpin,low);
       delaymicroseconds(delayvalue);
   }
}

this method blocking, since delay time depends on frequency. have @ tone library, non-blocking.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Simultaneous two Speaker Output


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums