Go Down

Topic: Digital Pins Problem (Read 6 times) previous topic - next topic

cr0sh

I recall there was a library or something (posted in the old forum) for performing PWM on many pins for control of an RGB LED array. Perhaps you could take that, build your own tone library over the top of it, and use that? Even so, it may not be fast enough for your purpose (that is, the tones won't have the range). I would suggest moving to the Mega, or alternatively, you could use two (or more) regular Arduinos, each sitting on an SPI or I2C bus, one master - each outputting 3 PWM channels. Finally, unless you need or want the effect - you don't need 3 (or 6) speakers; use a simple audio mixer circuit instead.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

polonos13


you don't need 3 (or 6) speakers; use a simple audio mixer circuit instead.


How does it work the audio mixer circuit ???
Is there anything in the forum about the audio mixer circuit that i can find ?

Grumpy_Mike

First off don't cross post it really annoys people and wastes there time. Don't do it again.    :0

Quote
How does it work the audio mixer circuit ?

This is an external circuit that uses op amps and resistors to combine several signals, google it.
Quote
Is there anything in the forum about the audio mixer circuit

Probably not as this is more of your hi-fi audio circuit than your embedded processor circuit.

polonos13

I ve figured how to make my laser harp playing a little better than before.You see my problem was that when i had one speaker for producing the notes,when i interrupt one and only laser beam the tone played well.But when i was interrupting two laser beams at the same time the notes for each interrupted beam was played at the same time from the one and only speaker and the mixing of the two tones was awfull. Now i 've conncted 3 speakers and i have 6 laser beams. The first laser goes with speaker 1 ,the second laser goes with speaker 2 ,the third laser goes with speaker 3, the fourth lase goes with speaker 1, the fifth laser goes with speaker 2 and the sixth laser goes with speaker 3.The only problem is when i hit at the same time the laser 1 and 4 together or the laser 2 and 5 together or the laser 3 and 6 together because these pairs are using the same speaker. So i've changed my source code a little and if one of the 3 combinations comes up a totally different sound is played by the speaker connected with the pair.

Code: [Select]

#include <Tone.h>

int lightPin1 = 0;  //define a pin for Photo resistor
int lightPin2 = 1;  //define a pin for Photo resistor
int lightPin3 = 2;  //define a pin for Photo resistor
int lightPin4 = 3;  //define a pin for Photo resistor
int lightPin5 = 4;  //define a pin for Photo resistor
int lightPin6 = 5;  //define a pin for Photo resistor

int reading;
int reading2;

// You can declare the tones as an array

Tone aLaser1;
Tone aLaser2;
Tone aLaser3;
Tone aLaser4;
Tone aLaser5;
Tone aLaser6;

void setup(void)
{
  Serial.begin(9600);
  aLaser1.begin(3);
  aLaser2.begin(4);
  aLaser3.begin(5);
}

void loop(void)
{
  reading = analogRead(lightPin1);
  if(reading < 50)
  {
    aLaser1.play(130,400);
  }
 
  reading = analogRead(lightPin2);
  if(reading < 50)
  {
    aLaser2.play(140,400);
  }
 
  reading = analogRead(lightPin3);
  if(reading < 50)
  {
    aLaser3.play(160,400);
  }
 
  reading = analogRead(lightPin4);
  if(reading < 50)
  {
    aLaser1.play(170,400);
  }
 
  reading = analogRead(lightPin5);
  if(reading < 50)
  {
    aLaser2.play(190,400);
  }
 
  reading = analogRead(lightPin6);
  if(reading < 50)
  {
    aLaser3.play(200,400);
  }
 
 
  ////////////////////////////////////////////////////
  //         This is the code for the combinations          //
  ////////////////////////////////////////////////////

  reading = analogRead(lightPin6);
  reading2 = analogRead(lightPin3);

  while(reading < 50 && reading2 < 50)
  {
    aLaser3.play(220,400);
   
       reading = analogRead(lightPin6);
       reading2 = analogRead(lightPin3);
       if(reading >50 || reading2 >50)
       aLaser3.stop();
  }
 
 
  reading = analogRead(lightPin5);
  reading2 = analogRead(lightPin2);
  while(reading < 50 && reading2 < 50)
  {
    aLaser2.play(240,400);
   
       reading = analogRead(lightPin5);
       reading2 = analogRead(lightPin2);
       if(reading >50 || reading2 >50)
       aLaser2.stop();
  }
 
 
  reading = analogRead(lightPin4);
  reading2 = analogRead(lightPin1);
  while(reading < 50 && reading2 < 50)
  {
    aLaser1.play(260,400);
   
       reading = analogRead(lightPin4);
       reading2 = analogRead(lightPin1);
       if(reading >50 || reading2 >50)
       aLaser1.stop();
  }
       
}//void loop


http://www.youtube.com/watch?v=rr6iMBimriQ&feature=player_embedded

Go Up