I am using an UNO for my project.
My project is a musical instrument that generates a tone when the divided voltage reading through a photo-resistive cell dips below a threshold. There are multiple sensors, each with its own speaker. The problem I am having is that when one tone initiates on one speaker, no other tone will play on the other speakers. I believe there should be no problem generating 2 or more distinct PWM signals to the speakers. I have looked at manipulating the PWM frequencies more directly, but I believe I am limited by the discrete set of divisors.
This is a stub of the code to illustrate the scheme, and perhaps highlight any causes of my problem:
void setup() {}
void loop() {
if (sensor1 < threshold1) tone(outputPin1, frequency1, duration1)
if (sensor2 < threshold2) tone(outputPin2, frequency2, duration2)
}
If I trigger the sensors simultaneously, the first tone to play will continue to do so until the trigger action is disengaged, while the other remains silent. My desire is to get any speaker to play at any time, regardless of other speakers playing.