LightMeUp! a Realtime Cross-platformed LED Strip Control

757

12

3

Introduction: LightMeUp! a Realtime Cross-platformed LED Strip Control

LightMeUp! is a system I invented for controlling a RGB LED-Strip in realtime, while keeping the cost low and performance high.

The server is written in Node.js and therefor cross-platformable.

In my example, I use a Raspberry Pi 3B for long term use, but my Windows PC for sakes of demonstration and debugging.

The 4pin-strip is controlled by a Arduino Nano type-board, which executes serially given commands to send PWM signals to three transistors switching the +12VDC into the corresponding color-pin of the strip.

The LightMeUp! system also checks it's own temperature, once it is above 60°C (140°F) it turns on two 12VDC computer fans built into the casing, in order to cool itself down to improve circuit lifetime.

Another feature of LightMeUp! is to illuminate a Bombay-Sapphire Gin bottle, but that is not the focus of this Instructable.

Enjoy reading :)

Supplies

  • Arduino Nano (or any other ATmega328 / higher-based microcontroller)
  • Raspberry Pi 3 Model B with Node.js installed (or any other computer)
  • 12V RGB 4-Pin LED strip
  • 12V 3A Power supply
  • Jumper cables (male-male if you use a breadboard, of course)
  • Breadboard (optional)
  • 2 12V DC computer fans (optional)
  • 3x TIP120 Darlington Transistor w/ heatsink (4 if you want to include cooling fans)
  • 2 status LEDs red and green (optional)
  • 6,7K NTC temperature-based resistor + 6,7K resistor (optional)
  • USB-Mini to USB 2.0 data cable (for the Raspberry Pi to communicate with the Arduino)
  • Externally powered USB-Hub (optional, only for Raspberry Pi)

Step 1: Understand the System

LightMeUp! is based on very simple electronic circuitry.

We have some kind of computer (in this case a Raspberry Pi) which communicates serially with our microcontroller board. This board then executes specific serial commands like "RGB(255,255,255)" which would turn our LED-Strip white.

Once we got our three values for RED, GREEN and BLUE necessary for our 4pin LED-Strip we execute analogWrite(pin, value) in order to supply our TIP120 transistor with a PWM signal.

This PWM signal allows the transistor to switch the corresponding color pin it's collector is connected to to ground, to a specific degree or completely on / off. Yes, a lot of "to"s :)

By mixing the three transistors outputs to the LED strips' color pins we can create basically any color we want!

Now with this understanding, we can attack the biggest challenge of this project, the websocketserver and its serial connection to our Arduino.

Step 2: Writing the WebSocketServer

Now, we have to create a specific kind of webserver, that allows us to transfer data back and forth without refreshing once in order to achieve a realtime LED strip control.

Please note, that realtime communication of course is impossible, there will always be atleast a few miliseconds of delay involved, but to the human eye it is considerable as realtime.

This can easily be achieved by using the socket.io library if you use Node.js like I did. However, you can always stick to your favourite programming language, of course.

We will be dealing with a websocket connection which allows us to transfer input data like which color you want to set the LED-strip to, or status data like "LED ON" bidirectionally without refreshing.

Another very important feature the server should have but doesn't need to is a simple login. I based my login off of a simple username and password field. These pieces of information are then posted to the /login route of the server, which then compares the username to a list of users (.txt file) and its corresponding password in its SHA256-encrypted form. You don't want your neighbours to mess with your LED strip while you enjoy your favourite beverage on your most comfortable seat, right?

Now comes the heart of the server, the serial communication.

Your server must be able to communicate serially - in Node.js this can be achieved by opening a port using the "serialport" library. But first determine the name of your arduino port on your computer hosting the server. Depending on your operating system, the ports will have different names, a.e. on Windows these ports are named "COMx" ports, while on linux they're named "/dev/ttyUSBx", where x is the number of the USB port.

Step 3: Establish a Protocol of Serial Commands

In the picture above, you see the actual Arduino IDE code responsible for the RGB control. Goal of this step is, to make your self-written server and Arduino board talk to eachother successfully.

Once you opened your serial port successfully, you need to be able to send commands to the board which takes care of your wishes. For example, if we draw a finger above the color picker on the HTML webpage, the RGB code should be sent to the server which then sends it to your Arduino so it processes the values set.

I used jscolor, they have a great implementation of a high quality color picking element, which owns an event called "onFineChange" which lets your process data from the color picker as soon as it's values change.

Check out their page so you can implement their colorpicker in your projects, if you like to: jscolor

Step 4: Wire It All Up!

Now that you have successfully written a websocketserver, designed it's frontend and made it flawlessly communicate serially to your Arduino board and are basically ready to go, let's talk about the wiring.

I used a small breadboard, but you can of course stick to soldering, if you prefer.

  1. Make sure your external power supply is unplugged!
  2. Connect the +12V pin of the LED strip to your positive of your external power supply
  3. Connect the Arduino's ground, the negative of the power supply and all 3 Emitter pins of the TIP120 to a common ground
  4. Connect three PWM-capable digital pins of your Arduino to the Base pins of the TIP120
  5. Connect the Collector pins of your transistors to the RED, GREEN and BLUE pins of your LED strip
  6. Voilá, your'e basically done!

Now you can turn on your external power supply, plug in your Arduino board's USB to your host computer, start the server and test it out!

Step 5: Extra Tips to Improve Your Circuit

As you can see in the video, the circuit works well for me on PC as well as on my mobile (not seen in the video)

Update: A second video showing a demo using my phone (lmutvid.mp4)

No more hopeless IR-Remote button spamming madness ;)

If you want to improve the efficiency / security / lifetime of this circuit you can:

  • Use a temperature controlled fan as seen in the box
  • LED status lights to signal specific situations
  • Use heatsinks on your transistors, they like to get hot when you turn your LED strip white for a few hours
  • Any useful modification you can think of - your creativity is your limit!

I hope you had fun reading my first Instructable, if anything is unclear while building this circuit, you can of course mail me: eren.levent@web.de

If I find time, we can solve it via Discord or whatever :)

LED Strip Speed Challenge

Participated in the
LED Strip Speed Challenge

Be the First to Share

    Recommendations

    • Make it Fly Challenge

      Make it Fly Challenge
    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Backyard Contest

      Backyard Contest

    3 Comments

    0
    Elaina M
    Elaina M

    1 year ago

    Good project - thanks for sharing. Are you going to tell us more about that Bombay-Sapphire Gin bottle???

    1
    tnevel_xd_xd
    tnevel_xd_xd

    Reply 1 year ago

    Thanks for your kind comment!
    I used a cable box, cut a hole for the 12v 10W LED in it's middle,
    mounted the heatsink to the LED chip, glued that into the hole so you got a flush
    surface with a LED in the middle, on which the bottle then stands.
    Hid all the electronics including the 5v relay (with a kickback diode protecting your Arduino) inside the cable box and connected the 2 1m long wires to the Arduino.
    I used a 2n2222a transistor, connected it's Base to a digital Arduino pin, it's Collector to the negative of my LED/relay wire, the positive LED/relay wire to the 5v Arduino pin, and it's Emitter to ground. Note: I used a 9v power supply for the LED, 12v was too bright for me. Look at some of these pics / vids:

    1587049936135.JPEG1587049938383.JPEG1587049936798.JPEG1587049935367.JPEG
    1
    Elaina M
    Elaina M

    Reply 1 year ago

    That looks so cool ! I love the affect that glass has on light - Thanks for showing me this part of the project :)