LED controller (with Arduino, RaspberryPi and WebSockets)

I haven’t posted here for a while so I figured I’d write about this little project I made some time ago.

I’ve had an aquarium for some time but it had no lights so it didn’t look that cool during the dark time of the day.

I had an old Arduino Uno lying around from times before RaspberryPi and it just so happens that Arduino has 5 PWM output pins and I only needed 3.

rjb_all

I connected a single RGB LED and a couple of white LED’s (which is enough to light a small aquarium properly) to the Arduino and made the program use serial connection to send and receive JSON formatted data.

276dbbe0a49111e280cd22000a9f18de_7

Then I connected Arduino (using USB) to my RaspberryPi that I use as a home server and wrote a Perl script that connects to Arduino’s serial port (using IO::Async::Stream).

IMG_20140118_214635

The Perl script creates a WebSocket server (using Net::Async::WebSocket::Server) that allows realtime control of LED’s and color modes from a web browser.

2014-01-19-111507_456x524_scrot

In the future I could tweak it a bit more and bring back the scripts that I used to switch on LED’s based on events from IM clients (Pidgin/Skype) or E-mail but at the moment I’m happy with it as it is.

Join the Conversation

2 Comments

  1. hei. es skatos, tu esi izdarījis kaut ko tādu, kas man tuvākajā laikā varētu noderēt – es gribu kaut ko līdzīgu iemontēt gičā iekšā, arī ar RGB LED’iem un Arduino. tikai problēma, ka es par to diži daudz neko nezinu. vai ir iespējams no tevis iegūt kādu shēmu, koda rindu un/vai padomu? liels paldies.

  2. Jēe!
    Es arī esmu līdzīga projekta skatienos.
    Tieši ar Arduino.
    Raspberry šajā gadījumā kalpo par serveri.
    Arduino aiztiek regulējamās lietas.

    Gribum gribu 🙂

Leave a comment

Your email address will not be published. Required fields are marked *