Light it up!

So I got myself a 1m strip of WS2812B LEDs or commonly known as individually addressable 5050 LED ICs. I saw a lot of youtube videos on infinity mirror and thought if the same concept can be applied to creating a clock and voila! lots of people have already done that in the past.

To be very honest it doesn’t not look like a very difficult project to accomplish. So I went ahead and got myself an Arduino Mega Rev 3.

Here are the steps I used to make the LEDs glow like a clock hands move.

  • My first step was to find a suitable power supply, I didn’t get one with the strip so I just had to search for my mobile chargers and check which one was suitable. Most of them had a voltage rating of 5V but I needed one with a higher Ampere rating.

Each 5050 LED IC needs around 60mA and I had a total of 60 LED ICs.

So power required is simply = 60 * 60 mA = 3.6 A

Thankfully my One Plus phone charger had a 4A rating. So it fit the budget just fine.

  • I simply cut the USB cable I had with the charger and found the two thicker wires which had to be the ones with +5V and Neutral. I checked it with my newly bought Mastech Multimeter to confirm.

Excited that the power supply of my mobile charger met my LED requirements so amazingly I connected both and turned on the power.

Aaanddd!! it did not light up 😦 I thought maybe my connections are weak, so I redid them again and again and again and it never worked. The LEDs just wouldn’t light up.

I tried to measure the current flowing through the LED strip and there was definitely current flowing through so the circuit was continuous. So even if some of the LEDs were not working, some of them should have lit up. I spend the next few hours trying to test if power is flowing through LEDs randomly and it was.

But still no glow.

Google didn’t help all that much since I never thought that the strip didn’t light up coz I was not sending any control/data signals to it.

Finally I figured it out the next day, I connected it to my arduino and imported the FASTLED library. The code sample was easy enough to test and I modified it as per my LED Strip and here is the code to run a simple clock on a LED Strip with 60 LEDs.

#include <FastLED.h>
int led = 13; // Usually the orangle led is set at pin 13.
#define LED_PIN 6 // data pin to be connected to WS2812B
#define NUM_LEDS 60
#define LED_TYPE WS2812B // make sure to choose the correct LED TYPE.
#define COLOR_ORDER GRB
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 60
bool gReverseDirection = true;
CRGB leds[NUM_LEDS];
void setup() {
pinMode(led, OUTPUT);
delay(2000);
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
// the loop routine runs over and over again forever:
void loop() {
delay(1000); // wait for a second
leds[0] = CRGB::Red;
leds[1] = CRGB::Orange;
leds[2] = CRGB::Green;
FastLED.show();
delay(1000);
FastLED.clear();
}

Hope this helps anyone who is just starting up. I will post the code for lighting up the LEDs like a clock in the next blog post.