Introduction: Intel Edison and Addressable LEDs

One of the first things that I like to try when I get a new development board is to get LEDs working on it! I start with a few solitary LEDs and quickly progress to programmable LED strips and matrices.

The Edison is a fun board because of its small footprint, relatively low power use and the built-in wifi and Bluetooth connectivity.

In this Instructable I will be using the Edison with Arduino Breakout Kit, Seeed Studio's Grove sensor kit, WS2801 LED pixels and Node.js to prototype. By the end of it, you should have an Edison controlling addressable LEDs by push button or via messages from an MQTT server.

This is a work-in-progress and the start of a more ambitious project. Most of my work with LED strips has been with C or Python, but I thought I'd take advantage of Intel's extensive JS developer tools, use this as a fun exercise to get some LED patterns running in Javascript.

At this stage my results still have some rough edges and flicker, and I consider this project to be at an intermediate level, but I'm sure others will find it fun. Expect a second Instructable where I add some polish and cover more detail on the enclosure and interface of what I'm building!

Note: The lights I'm using are WS2801 and have a data and clock line, they are not the very popular WS2812B Neopixels. The Edison has a powerful real-time Quark MCU that is not yet active, but that should easily drive WS2812 lights when the appropriate software update and docs are released.

What you need:

* Intel Edison and Arduino breakout board

* Grove Starter Kit for Intel Edison (We're going to use the push button and RGB LCD)

* 1 meter, 4-wire, SPI based LEDs (I'm using WS2801; as a note, these are not the very popular WS2812 Neopixels)

* Power supplies: 5V (for LEDs) and 12V (for Edison on breakout)

Step 1: Set Up Your Hardware


Power
Your Edison needs power. With the Arduino breakout it will need a 12V power source. A nice 12V 1 or 2A wall wart should do the trick.

Your LEDs are going to draw a LOT of power, so it's really not a good idea to run all of that through the Edison or breakout board. It's possible, like in my case, they'll even run at a different voltage. Let's give them their own power supply!

Plug the Edison in, simple, you're done :D

Now for the LEDs. Find a V+ or 5V and GND on your LEDs. Run these two lines to their counterparts on a wall wart of appropriate voltage, that is capable of putting out at least several amps! I really like these using barrel connector-to-wire adapters (second picture) to make my connection, you can find them around online, or over at Adafruit.

Button and LCD

Connect your Edison to the breakout board. Place the Grove shield on top. Connect your push button to the D6 port and your RGB LCD to any of the available IC2 ports. It's all simple and a snap in.


LEDs


Ok, on the shield are a bunch of ports for I2C, but you said on the first page we need SPI for these LEDs. Where is this? What's going on? With the Arduino breakout shield on the Edison, the pinout for SPI is conveniently the same as Arduino! And Arduino uses pins 11-13 for SPI. So here's what you do:

* Connect a ground from the LED strip or your LED power supply to the Arduino shield Ground (there's one next to Pin 13)

* Connect Pin 13 on the Grove shield to the LED strip Clock (CL) Pin

* Connect Pin 11 on the Grove shield to the LED strip DATA (DI) Pin

Voila, everything is connected!

Step 2: Setup Your Software

There are a few different piece of software that you'll need to get this sketch running!

Edison Setup
First, make sure you have your Edison setup, connected to wifi and running the latest image of Yocto. Intel provides a getting started guide here, and there are several good Instructables on this process, so I'm not going to go in-depth on it.

MRAA

The library that we're going to use to interface with the GPIO pins and SPI is called MRAA and is provided by Intel. It's very important to make sure that you update MRAA to the latest version. Without an update you may be missing features or the sketch may error out. Connect to your Edison via ssh or a serial port and follow these Instructions at the prompt (you can also find them at the library's Github repo):

echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
opkg update opkg install libmraa0

Node code
Grab this Gist with my prototype code.

You can also clone it with git:
git clone https://gist.github.com/ae472b32b694ab74d57f.git


You'll install the js files and package.json on the Edison. Using index.html and message.php are optional, but you can upload them to cheap webhost of your choice, or host them locally on your computer.

Step 3: Upload to Edison Using Intel XDK IoT Edition

The Intel XDK IDE allows you to develop your code in JavaScript, then easily upload, build and debug your code on the Edison. You can download this IDE here. It's free and comes with a bunch of helpful examples.

If you're unfamiliar with node, or this IDE, I recommend walking through a few of Intel's sample projects. Blink a LED, click a button, read a potentiometer, etc.

Here are the steps to get these LEDs running on your Edison:

* Create a blank project and add the js and .json files from the Gist to your project folder.
* Find and connect your Edison using the drop-down menu in the bottom left side of the interface.
* Once connected, use the buttons next to the menu to upload, build and install your project.

This process may take a few minutes but with any luck you will be up and running. You will know everything is working correctly when your LCD light ups green with the word "Hello!"

Step 4: Cycle Your LED Patterns, Hack Away and Enjoy!

You're set to enjoy your LED Light show! Make patterns of your own, share and have fun.

There are two ways to cycle through the LED patterns:

1. Press the physical button.

2. Send a message to the 'myledtest' endpoint of the public MQTT broker at iot.eclipse.org.

The second option sounds complicated, but it's not too crazy, I promise. One of the best features of the Edison is the wireless/Internet connectivity. The example code connects to a public MQTT broker which allows your Edison to send and receive messages via the Internet.

MQTT works a bit like a chat server. Your device connects and subscribes to a channel hosted by a broker, when new notifications are available they are pushed to it. A device can also publish to a given channel or channels.

In this case the Edison is subscribed to a channel 'myledtest,' and in my simple example, every time that channel gets a new message, the LED pattern changes.

You can publish messages to MQTT from the command line, but a more intuitive interface is a web app! That's where index.html and message.php come in. They are a barebones web to MQTT example: you a single button that publishes a message to the 'myledtest' channel on a MQTT server. Your Edison is listening and whenever a new message appears it changes the LED pattern. As you might imagine there are many ways you can expand upon this, developing more direct and granular LED control, even two-way communication!

Happy hacking!

Comments

About This Instructable

8,202views

32favorites

License:

Bio: Sharing knowledge and ideas. Constantly learning!
More by danasf:Intel Edison and Addressable LEDsInternet of DucksLighting In A Bottle
Add instructable to: