Does anyone have a schematic on how to wire up a RGB LED and Piezo Element with an Arduino Uno? What I'd like to do is illuminate different colors on the RGB LED which activates a different sound out of the Piezo.
For example:
When RGB LED is RED (0xFF0000) the Piezo produces "jingle bells"
When RGB LED is GREEN (0x00FF00) the Piezo produces "deck the halls"
I will trigger the LED by sending controls through the serial port. The problem I have is wiring up the circuit. I can't figure out how to wire it up correctly. Here is what I have:
Arduino pin #9 to Piezo Element
Arduino pin #9 to 330 ohm resistor to red pin of RGB LED
Arduino pin #10 to 330 ohm resistor to green pin of RGB LED
Arduino pin #11 to 330 ohm resistor to blue pin of RGB LED
The problem is Arduino pin #9 is trying to control the Piezo element and the red pin of RGB LED. If I run the LED with out the Piezo it works, if I run the Piezo without the LED it works. But they don't work wired together as stated.
No they won't and they never will, you need to use a different pin for each thing you need to control.
So use another pin.
Then have the routine that triggers the LED to light also call a function to play a tune with the tone pin.