I am looking to use my Uno to control my 8 Channel SainSmart relays. I know how to get the relay module to work, so no worries there. My question is about the coding. I want to make my Chrismas lights light up as if each strand is a note in a song. I would love to eventually incorporate sounds, but for now I want to just have the lights represent the sound. I don't want to spend the years of coding required to code each note for several songs. Is there a quick way of putting the notes into a program and getting out some kind of code I can put in Arduino language? I am hoping to do 3 to 4 common Christmas songs.
I have not yet started to work on this yet, but I plan on doing a similar project. My concept is to just run an audio line to the analog ins (not sure if this can be done directly or if I need to add components in between). Then map the analog input to the analogWrite of RGB LEDs, so they will change with the music.
I know that may not be particularly useful, but I'd be interested in what you come up with.
There could be two ways to approach this, the first way to to enter notes manually like the melody example, then "map" each note to a relay.
The other way is use a MSGEQ7 chip http://www.cmiyc.com/projects/msgeq7-simple-spectrum-analyzer/ and write code to control the relays/transistors or FETs.
Though I have not tried them I know you can get programs to convert midi to csv files. Get online midi version of your tune and convert it to csv. This csv file would hopefully contain the relevant data you need (Note, duration & time) and should cut and past into an arduino sketch with little modification. The clever part will be writing a program to convert this into your flashing light sequence.
Where's the music coming from?
...8 Channel SainSmart relays.
You do know that there are 12 notes in an octave, and some songs span more than one octave? ;) Although almost no songs use all 12 notes, so the lights can represent differnt notes (a different key/scale) for different songs.
If you are "computer generating" the music, then [u]MIDI[/u] would be the best solution. You would make the light as-if you are making an MIDI instrument, except lights blink instead of sounds/notes. Then changing the song simply involves loading a different MIDI file. And, you can use any MIDI controller (or a computer) to and any MIDI instrument (or computer) to play the music. MIDI can play different instrument sounds (but not vocals/lyrics) and it can play chords (more than one note at a time). You can find MIDI files on the Internet, and the classical traditional Christmas carols are long out of copyright, so you should be able to find them free. The thing is... I doubt you can complete that project by Christmas.
The MSGEQ7 chip will respond to audio frequency bands, but two notes that are close together will activate the same lights. This is probably the simplest solution if you want to be done by Christmas. And, it will work with any CDs & MP3s that you have.
The 3rd option is to get a sound shield and "manually" program simple tones/notes and the lights together. That shouldn't be that much work (for a few songs) because once you write some functions (or a function) to take a note and duration as input, and create the tone & trigger the light, it's just a matter of entering/adding the notes & duration for the varous songs.
rogue_wraith: My concept is to just run an audio line to the analog ins (not sure if this can be done directly or if I need to add components in between).
Absolutely. Audio directly into the Analog Input will destroy them. Line-out is such a small signal you'll at least need an amplifier. Also the A/D only samples about 10k per second, which is relatively slow for Audio.
Lakes: The other way is use a MSGEQ7 chip http://www.cmiyc.com/projects/msgeq7-simple-spectrum-analyzer/
I don't know if I would trust that guy's projects... ;)