After receiving my package a few weeks back the first few things I did after stetting up the latest version of the Yacto image, and testing the python UPM examples for SeeedStudio sensors which I plan to use for the build , I tried testing Neopixel strip (WS2812), which is one of the most important part of the build. After finding out there was no UPM example and after trying Adafruit's Arduino library for a couple of hours with the Intel Edison and then back to the Arduino Uno to check if all the connection are ok .. By this time I had also consumed a couple of Red bulls just to see I can grow wings . I then resorted to searching the internet to see if there was something with respect to the Intel Edison and Neopixels WS2812, and lo and behold I was taken to the Intel communities web site where I found a couple of threads showing why the Neopixels WS2812 is not supported/won't work with the Edison.
Here is details from intel forms which best desribes the issue with using WS2812 - https://communities.intel.com/message/315650#315650
“ you won't get consistent write times since clock cycles for any Arduino commands like write are non-deterministic. The reason is because the Arduino on Edison runs as a process within the Linux system, where execution is controlled by the kernel and also shared with other processes.”
This meant I had to think about alternatives, and based on the forum post on Intel communities, I decide to buy a LED RGB strip(APA102 LED) from Sparkfun- https://www.sparkfun.com/products/14015. Here is a brief description of LED Strip –“These are addressable 1-meter-long 5V RGB LED strips that come packed with 60 APA102Cs. APA102 LEDs are very similar to WS2812s with a few caveats: APA102s can be controlled with a standard SPI interface, and they have an extremely high PWM frequency. There is access to each APA102 LED, and each strip length can be easily modified. You will be able to control each LED RGB individually”
And after receiving the package, I was finally successful in getting the new LED strip cycling through colors . Here are some details of the testing setup..
For the circuit as show in the picture below, I used
Pot connected to A0 – this is to test the various color of strip
To power the LED strip , I am using 4x AA batteries
Data – pin #11
Clock – pin #13
The python program is based on UPM example for apa102 LED strip
#!/usr/bin/python # Created by Carmelito to test LED strip and this is based on # Grove Pot https://github.com/intel-iot-devkit/upm/blob/master/examples/python/groverotary.py # Led Strip https://github.com/intel-iot-devkit/upm/blob/master/examples/python/apa102.py from upm import pyupm_grove as grove import time, sys, signal, atexit from upm import pyupm_apa102 as mylib from time import sleep def main(): # Instantiate the strip of 60 LEDs on SPI bus 0 connect Data-D11 and Clk- D13 ledStrip = mylib.APA102(60, 0, False) knob = grove.GroveRotary(0) abs = knob.abs_value() while True: # Read values abs = knob.abs_value() print("Abs values: " + str(abs)) lightValue = lightSensor.raw_value() print ("Light Value: " + str(lightValue)) sleep(1) if abs <100: print("Setting all LEDs to Green") ledStrip.setAllLeds(60, 0, 255, 0) time.sleep(2) elif abs >100 and abs <300: print("Setting all LEDs to Red") ledStrip.setAllLeds(60, 255, 0, 0) time.sleep(2) elif abs >300 and abs <600: print("Setting all LEDs to Blue") ledStrip.setAllLeds(60, 0, 0, 255) elif abs >600 and abs <900: print("Setting LEDs between 10 and 20 to Red") ledStrip.setLeds(10, 20, 60, 255, 0, 0) time.sleep(2) else: print("setting all LEDS off") ledStrip.setAllLeds(60,0,0,0) time.sleep(2) if __name__ == '__main__': main()
Here are few more picture which gives an insight on how I plan to use the RGB LED strip, basically an example here would be to have the LED strip turn bright yellow if it is going to be sunny today based on the OpenWeatherMap API which I used in a previous blog post -Upcycled Clock - Reading out the weather using eSpeak and blue if it about the rain so that you can remember to your umbrella with you..
{gallery} Testing RGB LED strip |
---|
Setting RGB LED strip to Green |
Setting RGB LED strip to Red |
Setting RGB LED strip to blue and then setting LED 10 to 20 to Red |
Top Comments