I love building things with Arduino, esp8266, and raspberry pi all the time and on Amazon Prime Day, I came across a deal on individually addressable LED strips (RGB LED strips) and decided to make something with them. So, I hooked them up in my room and made an Arduino controller with IR for them.Individually Addressable LED Strips
An individually addressable LED strip is a normal LED strip with a couple major differences. Each LED is a RGB LED instead of a plain white LED and each one can have it's color and brightness controlled separately. RGB stands for Red, Green, and Blue. So each LED actually has three separate ones inside. 1 red, 1 green, and 1 blue. You can learn all about individually addressable LED strips here.
After googling ideas, I found a guy who did a similar project here. I originally thought that I would need one Arduino, but this project uses two. I soon found out that individually addressable LED strips require precise timing. Do you know what else does? Yep, IR also needs precise timing because if the Arduino isn't available and listening at the exact moment the IR code is received, the code will disappear. So I'm using one Arduino for controlling the LEDs and another for the IR receiver, with serial as the link. Serial has a buffer so once the sending Arduino sends, the data sits there and waits till the receiving Arduino acknowledges it.Why not WiFi?
I absolutely love making things with WiFi. I even wrote three other tutorials on here using wifi devices. But, this is going above my bed in my room. WiFi has actually been proven to be dangerous. Especially so close to ones head 24/7. It would be awesome to control this using the Zebra widget in Blynk with exact color choosing, but I decided to go with the much less hazardous IR option, because this is to be near my head all night every night. You could make it so that the WiFi disconnects at night. Of course, you wouldn't be able to control the LEDs at night then. I might make another individually addressable LED strip project with that in mind.Power
Part way through, I came upon the problem of power for supplying the LED strip. For white (each red, green, and blue pixel on high), each pixel uses 60ma, 20ma x 3. For a 60 pixel strip, it would use 3600ma, or 3.6a. I'm using a 2.4a USB charging port and it seems to work fine, but I'm not sure if that would be a bad thing or what the downfall would be so if you know, just say so in the questions. Many places online or not supply 5v power supplies for LED strips with a lot higher output.
The setup is fairly simple and only needs a few things to get going.
1 individually addressable LED strip (I'm using a 60 pixel WS2812B strip)
1 IR receiver
1 IR control (or 2)
1 power supply
Schematic can be found here and below.
This is a description of the code settings for the IR receiver Arduino.
1 #define RECV_PIN 2
2 #define IRControlAmount 2 //1 or 2
3 boolean FindingCodes = true;
1 is the IR receiver pin. 2 is the IR control amount. You can either use one or two. 3 is for finding the IR codes of your control(s). Set this to true for finding the codes. When you press a button on the remote, a code will be printed to Serial with 9600baud. Keep track of which button you press for which code is printed and replace the codes in the loop. But you can't just copy and paste the IR codes into the code. First, paste the IR code into this hex to decimal converter and then paste the returned decimal into your code in the loop. If that was a little too convoluted, here's steps.
- boolean FindingCodes = true;
- upload code to IR Arduino
- press buttons on control while facing at the receiver and paste the correlating codes and number buttons in notes, notepad, pages, or a piece of paper
- paste IR codes into hex to decimal converter
- paste returned decimals into the code with the correct correlating IR control buttons
- boolean FindingCodes = false;
- upload code to IR Arduino
This is a description of the code settings for the LED strip Arduino.
1 #define LED_PIN 7
2 #define NUM_LEDS 60
3 #define bright 100
1 is the LED strip data pin. 2 is the number of LEDs in the strip. 3 is the brightness level for all the LEDs. Settings and uploading is a lot less complicated. I also added a lightning setting and a gliding rainbow setting just for fun. Just change the settings to suit, disconnect the RX and TX lines from Arduino to Arduino, and upload to your Arduino.Usage Guide
Each control button does something different. 1 - 9 are color buttons while 0 is white. The rest are explained in the picture below. To turn on the LEDs, just press any button and it will turn on. For example, if you press 1 while it's off, it will turn on red. There is no need to turn the strip off between color changes. To turn the strip off, press OK. To turn the strip on in lightning mode, press the left arrow and to turn it off, press OK, and then OK a second time. To turn the gliding rainbow on, press the right arrow, and to turn it off, press OK, and then OK a second time. To set the amount of LEDs the second control can control, press the STAR button and when a blue LED turns on, press the UP and DOWN arrows to change the amount. Press OK to set. To activate the second control, press the # button, and to deactivate it, press the same button again. NOTE: At the time of this writing, the brightness keys do not do anything but I will work on fixing that in later code revisions.
That's all for this project. You can change anything to how you like. I will be doing more code revisions soon, so keep an eye out. If you have any questions or pointers, please feel free to comment.