In an earlier post I enabled an Arduino Yun to be controlled by Windows Remote Arduino over WiFi. This project is a further extension of it in exploring what is possible with Windows Remote Arduino. This time i connected a LED strip (TM1803 based three wire LED strip from Radioshack) to my Yun and controlled its color through an Universal Windows App that uses Windows Remote Arduino. Here is the lamp in action.
(I realize that there is a lag in the video between the phone overlay and the lamp. Something wrong with my video encoder. Couldn't figure it out. Job for another day..)
Key Components
Aside from Yun and Windows Remote Arduino, the key components are:
1. LED Strip : Most of the LED strips have dedicated IC chips on them to control a fixed set of LEDs and communicate the data downstream to next IC chip on the strip. I used a Radioshack LED strip that uses TM1803. This is a small 1 meter strip with 10 chips controlling 30 LEDs.
2. Power Source: Most of the LED's strips would need a separate power source. Mine required a 12v power supply. Since the Yun is only a 5V device, the power source and Yun had to have a common ground. Even thought there are ways to use the same 12v power supply to drive both the LED and Yun, i chose to run them with separate power source and common ground.
3. FastLed Library:
This is an excellent Arduino library developed and maintained by Daniel Garcia and Mark Kriegsman. There is no other library that supports such a vast array of LED strips as this.
Wiring
Simple wiring steps:
1. 12V power adapter +V to RGB Led Strp +Vcc
2. 12v Power Adapter GND to Arduino Yun Gnd pin.
3. RGB Led Strip GND to Arduino Yun Gnd pin
4.RGB Led String Data Pin to Arduino Digital 3 ( ~ pwm)
Arduino can be powered with a battery or wall wart independent of the LED strip power. Here is my wired up Yun before installing it in the lamp.
Aside from Yun and Windows Remote Arduino, the key components are:
1. LED Strip : Most of the LED strips have dedicated IC chips on them to control a fixed set of LEDs and communicate the data downstream to next IC chip on the strip. I used a Radioshack LED strip that uses TM1803. This is a small 1 meter strip with 10 chips controlling 30 LEDs.
2. Power Source: Most of the LED's strips would need a separate power source. Mine required a 12v power supply. Since the Yun is only a 5V device, the power source and Yun had to have a common ground. Even thought there are ways to use the same 12v power supply to drive both the LED and Yun, i chose to run them with separate power source and common ground.
3. FastLed Library:
This is an excellent Arduino library developed and maintained by Daniel Garcia and Mark Kriegsman. There is no other library that supports such a vast array of LED strips as this.
Wiring
Simple wiring steps:
1. 12V power adapter +V to RGB Led Strp +Vcc
2. 12v Power Adapter GND to Arduino Yun Gnd pin.
3. RGB Led Strip GND to Arduino Yun Gnd pin
4.RGB Led String Data Pin to Arduino Digital 3 ( ~ pwm)
Arduino can be powered with a battery or wall wart independent of the LED strip power. Here is my wired up Yun before installing it in the lamp.
Software
The LED strips will be controlled by an Arduino Sketch using the FastLED library. The sketch will receive the color information from the Windows Universal App over WiFi through the Windows Remote Arduino's Firmata interface.
Modified Firmata
Instead of using the StandardFirmataYun as mentioned in the earlier project, i am using a stripped down version of the firmata sketch as i am interested only in handling the string message call back. The call back will accept a string with the format of "R,G,B" and parse it to provide the color information to the FastLed library.
The LED strips will be controlled by an Arduino Sketch using the FastLED library. The sketch will receive the color information from the Windows Universal App over WiFi through the Windows Remote Arduino's Firmata interface.
Modified Firmata
Instead of using the StandardFirmataYun as mentioned in the earlier project, i am using a stripped down version of the firmata sketch as i am interested only in handling the string message call back. The call back will accept a string with the format of "R,G,B" and parse it to provide the color information to the FastLed library.
Univeral Windows App
1. Create a new Universal Windows App in Visual studio
2. Prepare the UI. XAML can be found in GitHub repository.
3. The universal app establishes a Network Serial connection to the Yun's Linux Serial port. (Note: This works only if the Yun was prepared as per the instructions in the earlier project.). There is a slight variation in the initialization of the Windows Remote Arduino in this code as the "sendString" function is available only on the UwpFirmata class. So an instance of UwpFirmata should be initialized first and passed to the constructor of RemoteDevice. Then a network serial connection should be prepared and passed as parameter to firmata.begin.. Then the network serial begin() should be called to open up connection to Arduino. The WRA initialization code is listed below:
1. Create a new Universal Windows App in Visual studio
2. Prepare the UI. XAML can be found in GitHub repository.
3. The universal app establishes a Network Serial connection to the Yun's Linux Serial port. (Note: This works only if the Yun was prepared as per the instructions in the earlier project.). There is a slight variation in the initialization of the Windows Remote Arduino in this code as the "sendString" function is available only on the UwpFirmata class. So an instance of UwpFirmata should be initialized first and passed to the constructor of RemoteDevice. Then a network serial connection should be prepared and passed as parameter to firmata.begin.. Then the network serial begin() should be called to open up connection to Arduino. The WRA initialization code is listed below:
4. The app displays an UI element with a color gradient. The app uses the WriteableBitmapEx NuGet package to add some extension methods that makes it easier to pick the color at the screen location where the user touches. Initialize the writeableBitmap so that it can be reused. Code:
5. On Click/Touch event, picks the color at the touched point and sends it to Arduino Yun by using the firmata.sendString method. Making a "flush()" call after every send to ensure that the string is processed cleanly. I had issues without calling flush().
All source code is available at the following Github url.