Introduction: Voice Activated LED Lighting With Arduino

This project is an extension to the Speech Recognition with Arduino by leandro4b (https://www.instructables.com/id/Speech-Recognition…). However, instead of using 3 separate colored LEDs, I used a multicolor 4-channel RGBW LED Emitter. I had the opportunity of working at LED Engin last summer, which is why I was able to use the high power 4-die RGBW emitter ( LZ4-20MD00) for my project. You can purchase their RGBW emitter from Mouser here. I also got a lens that is paired with the emitter. This allows the colors to blend better, but it is optional for this project

The idea is simple: I want a voice activated LED program that allow me to change the color by modifying the amount of red, green, blue and/or white LED in the emitter. In addition to that, I wanted some preset functions where I can tell the light to "wake up", "go sleep" or display the colors of the rainbow in order.

How this works: BitVoicer (voice recognition program) takes in a voice input, recognizes it and transfer that into a string. Every time it calls that particular string, the Arduino program will tell the LED what to do.

For this project, I used:

Step 1: Setting Up LED Emitter and Heat Sink

When I got the emitter in the mail, It had no wires on them. The nice thing about the LZ4-20MD00 is that the LED is mounted on top of the MCPCB, which allows us to solder wires onto the LED more easily. There are 8 pads on the MCPCB- the data sheet tells me which pad is for which wire. I actually had some challenges while soldering the wires onto the MCPCB because the MCPCB sucks the heat away, making it difficult for the soldering iron to heat up the pads. I then realized that the data sheet actually had tips for soldering. For this particular emitter from LED Engin, I had to heat the emitter up with a hot plate to 125-150 degrees C before soldering the wires on. Caution: different manufacturers have different procedures for attaching the wires- make sure you don't overheat the emitter.

According to the data sheet (on pg. 7 and 15), these are the wires connected to each pad:

Pad 1: White Anode +
Pad 8: White Cathode -

Pad 7: Red Anode +
Pad 6: Red Cathode -

Pad 5: Green Anode +
Pad 4: Green Cathode -

Pad 3: Blue Anode +
Pad 2: Blue Cathode -

I suggest that you use colored tape to indicate which wire is for which color so that you don't get confused later on.

Since this is a high power LED, I needed a heat sink for the emitter so that the LED does not overheat.

I made a simple heat sink out of aluminum and attached it to the LED Emitter using screws.

Step 2: Hardware

Wire the the Arduino and LEDs according to the diagram above.

Depending on which 4-channel LED you get, you will need to get different power resistors for each channel.

For my RGBW 4-channel emitter, I looked for the Electrical Characteristics on pg. 5 of the data sheet, then determined the power resisters I wanted using the information. I looked for the forward voltage and the typical voltage drop across each LED, then I used ohms law to determine the resistor that should go with each color. Note that you should use 2W power resistors because these are high power LEDs.

For this LED Emitter, I am using:

  • 4 Ohm 2W power resistor for red channel
  • 2.7 Ohm 2W power resistor for white channel
  • 2.7 Ohm 2W power resistor for blue channel
  • 2.5 Ohm 2W power resistor for green channel

I am also powering the LED using the 5V source from the Arduino.

Step 3: Upload Codes and Files

After downloading BitVoicer and Arduino, I wrote some codes for Arduino and created a new file for BitVoicer. I have included both files in the attachment of this instructable. (Note: you will not be able to open the vsc file unless you have BitVoicer installed). To start the program, first upload the Arduino code, and then press the start button in the BitVoicer file.

LED is not responding to your voice? Check these things under Preferences (under File) for BitVoicer:

  • Bits per Second is set to: 115200
  • Audio input is Computer's Default Microphone
  • set the Port Name to the same port that is connected to the Arduino (named COM_)

If still doesn't work, try these things under Preferences (under File) for BitVoicer:

  • lower the Acceptable Confidence level
  • make sure the Computer's Default Microphone is set to your external USB microphone. Look for the microphone setting on your computer

To write the Arduino code, I first opened the file that leandro4b used for his Speech Recognition with Arduino project. From there, I changed and added some codes so that the LED does the command that I wanted to do. I added commands in BitVoicer, assigned each command to a string in BitVoicer, then programmed functions for each string in Arduino.

Since the code is a little long, I will only explain some of the functions right below.

Beginning of the Code: This is basically where we "set up" everything.

#include // calls bit voicer library
//Instantiates the BitVoicerSerial class
BitVoicerSerial bvSerial = BitVoicerSerial();
//Stores true if the Audio Streaming Calibration tool
//is running

boolean sampleTest = false;
byte dataType = 0; //Stores the data type retrieved by getData()
int pinR = 6; // set up pin 6 to be red
int pinW = 10; // set up pin 10 to be white
int pinG = 11; // set up pin 11 to be green
int pinB = 9; // set up pin 9 to be red
int lightLevelR = 0; // set up initial light level of red to be 0
int lightLevelW = 0; // set up initial light level of white to be 0
int lightLevelG = 0; // set up initial light level of green to be 0
int lightLevelB = 0; // set up initial light level of blue to be 0
int arch = 0; // this is a variable that we set that will bring up different loops
long randNumberR; // generates a random number for red (for Meow function)
long randNumberW; // generates a random number for white (for Meow function)
long randNumberG; // generates a random number for green (for Meow function)
long randNumberB; // generates a random number for blue (for Meow function)

Void setLEDs(): this is where we call a function after the BitVoicer transfer the voice to the string. Under void setLEDs, I have "wake up", "go sleep", "turn on/off red led", "turn on/off blue led", "more/less green" etc. I also have preset patterns such as "rainbow", "sunset" and "ocean blue".

Below is the code for the voice command "more blue"

else if (bvSerial.strData=="BBright") // if BitVoicer detects "more blue", then this function will run
{
if (lightLevelB < 255) // if the light level is less than 255, then we will add brightness to blue
{
lightLevelB += 85; // when the function is called, we will add 85 to the lightlevel for blue. You can add any increments of light level you want.
analogWrite(pinR, lightLevelR); //light level for red stays constant
analogWrite(pinW, lightLevelW); //light level for white stays constant
analogWrite(pinG, lightLevelG); //light level for green stays constant
analogWrite(pinB, lightLevelB); //light level for blue changes as we give this command
arch = 0; // we have to set the arch variable to 0 so it doesn't accidentally call anything in the loop which you will see next
}
}

For the patterns, we will be setting the function to the variable arch = (an integer). this arch = (integer) will call a loop in the void loop. This is because the patterns need to repeat until another function is called.

else if (bvSerial.strData=="Pomona") // if BitVoicer detects "pomona", then this function will run
{
arch = 8; // it will set arch to 8, which will bring up arch == 8 loop in void loop (see below)
}

Void loop: in order to create special patterns (i.e. rainbow, sunset, ocean blue), we have to have different functions under the loop.

"Pomona" is one of the preset functions under void loop. It displays the colors blue and white until another function is called.

//pomona
if (arch == 8) // I set the variable to 8 so that
{

//RGBW code for blue
analogWrite(pinR, 85);
analogWrite(pinW, 0);
analogWrite(pinG, 49);
analogWrite(pinB, 203);
delay(1000); //pauses before changing to white

//RGBW code for white
analogWrite(pinR, 0);
analogWrite(pinW, 255);
analogWrite(pinG, 0);
analogWrite(pinB, 0);
delay(1000); //pauses before changing back to blue
}

Random "Meow" function: Just for fun, I decided to write a function that will set random RGBW values. The LED colors will be random when I say "meow" to the microphone. To do this, I used the built in "random" in the Arduino program.

before void setup():

long randNumberR; // generates a random number for red (for our Meow function)
long randNumberW; // generates a random number for white (for our Meow function)
long randNumberG; // generates a random number for green (for our Meow function)
long randNumberB; // generates a random number for blue (for our Meow function)

inside void setup():

randomSeed(analogRead(0));

inside void loop ():

randNumberR=random(255); //generates random number between 0 and 255 for red
randNumberW=random(255); //generates random number between 0 and 255 for white
randNumberG=random(255);//generates random number between 0 and 255 for green
randNumberB=random(255); //generates random number between 0 and 255 for blue

also inside void loop():

if (arch ==9)
{
analogWrite(pinR, randNumberR);
analogWrite(pinW, randNumberW);
analogWrite(pinG, randNumberG);
analogWrite(pinB, randNumberB);
delay(1000); }

in void setLEDs():

else if(bvSerial.strData=="Meow") // if BitVoicer detects "meow", arch will be set to 9
{ arch = 9;
}

Step 4: Commands

I have several functions in my code. I have the basic turn lights off and on function. I also have a more red/white/green/blue function that allows me to create any color I want.

In the pictures above, I have the commands and what the LED does when it hears the commands. The blue chart has simple commands such as wake up, turn on/off while the red chart has commands that calls for patterns.

See the videos below for the demonstration of the project.


Step 5: Conclusion and Next Step

The way I approached the project was by first recreating Speech Recognition with Arduino exactly the way that leandro4b did. When that did not work out, I went back and checked my wiring, Arduino and BitVoicer. It turned out that I did not set the BitVoicer up correctly initially, which is why it wasn't sending information to the Arduino. For more information on how to set up BitVoicer, please read the manual here.

After I made sure that my first prototype was working, I added a fourth color since the LED I was using has 4 colors. With that, I modified the code for the Arduino program by defining another pin as the input for the fourth LED. From there and on, I changed and added some codes so that the LED does the command that I wanted to do. I added commands in BitVoicer, assigned each command to a string in BitVoicer, then programmed functions for each string in Arduino. After I made sure everything worked, I transferred all the wires and resistors and soldered them all onto a perfboard.

What I learned through this project is that as I make modifications, I need to constantly checking both the software and the hardware of the Voice Control LED. I did that so it would be easier for me to troubleshoot when something is not working.

Next Step:

The next steps for this project is to increase the current to 700mA. Right now, although the Arduino is supplying 5V, it is not supplying enough current for the LED to use its full brightness. Increasing the brightness will allow the 4 colors of the RGBW emitter to blend even better. In order to increase the current, I will have to use an outside 5V supply while using a darlington to control the current. If possible, I would also like to try to use current drivers for my projects. If I am able to set that up, I would be able to supply enough voltage and current through even more powerful LEDs.
In addition to that, I would like to further finalize the project by adding a microphone to the circuit connected to the Arduino UNO and being able to control the lights with wireless control.

Lamps and Lighting

Participated in the
Lamps and Lighting