Volume db lvl decides RGB output HELP ):

Hey there, New to Arduino and basic robotics. Im confused about my current project and Im not sure what hardware to use, im not sure if its even possible. I would love some guidance as I am a newbie. But basically Id like to control an RGB strip or set of lights with volume levels. Example when the input receives 5db it triggers blue 10 for red etc. Im not sure what hardware i would need and also have no idea where to start coding or how to find one. Help Please!

Im not sure what hardware i would need

Something to measure the volume level would be the first thing you need. Perhaps a microphone.

Some LED strip(s) to control would be a good idea.

Some means of powering the strips would be useful (the Arduino can NOT power them).

Reading the microphone is easy, using analogRead(). Interpreting the data is not.

I think starting even with basic tutorials like:

A) Blink
B) Serial
C) AnalogInput
D) Map

Further on, id look at:

A) Op-amps
B) Transistors
C) MOSFET(s)
D) Passive mic

Then:

A) i2c protocol

This is not a very simple project for a beginner...
Start with the blink tutorial.

[u]Here is a solenoid driver circuit[/u]. You can use the same circuit to drive an LED strip except you don't need the diode. Of course you'll need 3 of these for 3 colors. (Or, you can use similar MOSFET circuits.)

The Arduino can't read the negative half of an AC audio waveform, and in fact it can be damaged by negative voltages. For a line-level or headphone-level signal you can use [u]this circuit[/u] to bias the signal so it doesn't go negative. With the bias, silence should read about 512 on the Arduino's ADC and audio signals will push the readings above & below that.

If you want to pick-up sound from the air, a [u]microphone breakout board[/u] is the best way to go. Most have the DC bias built-in.

Take it one small step at a time...

For example, you can start with the output or the input...

For the output, wire-up one LED color and driver and connect it to pin 13 so it blinks with the on-board LED when you run the Blink Example.

Then add the other two LED colors and write some code to control/blink/sequence them, or whatever you want to do as a test to make sure you can control them.

On the input, just run the Analog Read Serial Example to see what kind of readings you're getting.

Then, write some code that turns on an LED when you hit a certain threshold. i.e. Use an if-statement to turn-on the LED when the reading goes over 100, or whatever level works from the readings you're getting. You can subtract-out the 512 bias if you wish.

Once the input & output are working, you can add a couple more if-statements to trigger the other colors.

------------------------------------
Some things you need to know to "finalize" your software...

[u]Here is a simple introduction to digital audio[/u]. Audio (acoustic or electrical) is a continuously varying wave. It passes-through zero twice per cycle. i.e. If the peak is hitting +10dB, it will also pass through +5dB and 0dB, etc. If you run the Analog Read Serial Example, you'll see lots of random-looking numbers, but you should get a wider range of numbers with louder sound.

So, you'll have to look for the peak or take a short-term average in order to trigger you LEDs properly. A peak-level meter usually looks for the peak and then holds it for 1/10th of a second or more. A true-VU meter takes a kind of average.

Decibels are logarithmic and relative... Without a reference, 5dB or 10dB is meaningless. Sound (in the air) is measured in dB SPL (Sound Pressure Level) where 0dB is (about) the quietest sound a person with normal hearing can hear.

You can look-up how decibels are calculated but a handy thing to remember is that 6dB is a Factor of two. So, if +6dB happens to read 100 on the Arduino, +12dB will read 200 and +18dB will read 400... 0dB would read 50 and -6dB would read 25. (Those are made-up numbers.... Without calibration or a reference, we can't correlate the ADC reading to dB.)

5 or 10dB SPL is very quiet and unless you're in a soundproof room, the background noise is probably above that where you are right now.

If you want to calibrate your setup to a particular SPL level, you'll need an SPL meter to calibrate your project.

With digital audio files, 0dBFS (decibels Full Scale) is the "digital maximum". "Normal" WAV files are limited to 0dBFS and analog-to-digital converters & digital-to-analog converters cannot go over 0dB. So, most digital audio is read as a negative dB level.

Electrical audio signals are also usually referenced to the expected maximum, so most electrical audio signals also have a negative dB value.

Thank you for the replies and insight. Excellent, this is exactly what I was looking for DVDdoug. I will update with info regarding this project.