Sunday, September 28, 2014

Adafruit NeoPixels + Windows Phone 8

This is something that i wanted to do since a long time. Individual control of RGB LEDs on the Adafruit NeoPixel Shield over a bluetooth connection using my Lumia 920 running the Windows Phone 8, After extensively surfing MSDN help articles on WP8 APIs etc - Finally finished it this weekend.

Find the updated design, click here

In brief the design goes like this - An Adafruit NeoPixel shield containing 40 WS2812B 4-pin chip RGB LEDs in a 5 x 8 matrix pattern is mounted on an Adafruit Bluetooth Shield, the EZ Link which is stacked over an Arduino UNO. The code running in the Arduino reads the commands received on the serial bluetooth link, parses it and controls the RGB LEDs. The command packet sent from the Windows Phone consists of 5 fields - two fields for the X and Y co-ordinates of the LED and 3 fields for the R,G and B data obtained from the color picker.

The application on the windows phone is simply a grid of tiles created using the Coding4Fun WP toolkit. Each tile is identified uniquely by its name. Each tile can be set to a different color when clicked and has a one to one mapping with the LEDs on the adafruit shield. The color can be previewed in realtime. Some application statistics and setup are shown in below images. Once the code is well-organized i shall put it up here, and no, i did not write 40 event handlers for each of the tiles. There is only one event handler to rule them all :P

Once powered up the Arduino waits for a command on the BT Serial interface. When the application is started on the windows phone it establishes a connection with the BT module. On clicking any of the square tiles in the main application window another window opens up from where the color for that particular LED can be chosen. Alternatively all the LEDs can be turned off using the Turn Off button. The two wires in the pic below are the RX/TX pins from the BT shield connected to the Arduino over the SoftSerial interface...

P.S - The red color of the tiles is the default theme color on application startup. The LEDs do not get affected by this color unless programmed to

Here is an earlier experiment with a s ingle RGB LED breakout using Processing. The code for this can be found in the description of the video....

No comments: