The first component we need to get working is the LED strip. In this case we are using a 1 meter strip of APA102 that has 36 individually addressable LEDs. We are using these instead of the more popular WS2811/WS2812 strips because they use separate wires for their clock and data signals. The different versions of the Intel Edison firmware have issues which make them difficult to interface with the 3 wire LED strips, so using the WS2811/WS2812 strips is problematic.
To control the LED strip we need four pins on the GPIO as shown here:
GND --> GND
DI --> PIN 11 (MOSI)
CI --> PIN 13 (SPI Clock)
5V --> 5V
The important issue here is identifying the proper pins on the Edison Arduino board. The Intel Edison Kit for Arduino Hardware Guide ( http://download.intel.com/support/edison/sb/ediso... ) identifies those pins as the ones needed for “SPI send data” (PIN 11) and “SPI clock control” (PIN 13).
Now that the proper pins are identified we have to write some code to push the LEDs. None of the existing libraries like FASTLED or NeoPixel work with the APA102s and the Edison so we’ll need some custom code. The best explanation I’ve found is in the Intel Community forums here: https://communities.intel.com/message/335874#3358... . Basically, we need to create a Buffer object and then assign the RGB color values by passing them through the Buffer. Once you have the APA102 strip connected to the pins as described, you can run the following code to test the system. Note that since we are only using a couple of LEDs at a time in the final project, we won’t be using an external power supply.
The LCD we’re using is the “Grove - LCD RGB Backlight.” It comes as part of the Grove Starter Kit Plus from SeeedStudio and is also available separately. To connect it to the Edison we’ll use the “Grove Base Shield” and one of the included four wire cables. Once it is connected you’ll need to download the “Grove_LCD_RGB_Backlight” Arduino Library from: https://github.com/Seeed-Studio/Grove_LCD_RGB_Bac... . You’ll then need to put a copy of the “libraries” directory for your Arduino IDE installation. Once you get the library files in place you should run the “fade” or “HelloWorld” example scripts as shown in the image.
The Intel Edison comes with all of the features of an Arduino WIFI shield, so no additional hardware or shields are needed for the Arduino side of the Edison to access the WIFI systems. Now we just need to setup them up and test them. To do that, you’ll open the Arduin IDE and run the example sketch “SimpleWebServerWIFI.” If your Arduino IDE install didn’t come installed with the “wifi” sketches, you can download them from github ( https://github.com/codebendercc/arduino-library-f... ). Now you just need to customize the sketch with your network’s SSID (name) and password, and you should be good.
Putting it all together
Now we just need to write a sketch that will utilize all of the parts we’ve just setup. Here is the sketch you’ll need:
I’ve tried to comment out the sketch to answer any questions, but here is a quick overview of the sketch.
- The first 70 or so lines define the required constants, define some needed variables, and “include” the necessary libraries.
- The next 100 or so lines are the main “loop” of the sketch. Here the initialized webserver is waiting for incoming connections. When a connection is encountered, it tries to identify it as a weather code “WW” or as a temperature code “ZZ”. If either of those as found then the proper LED are lit and/or the proper message is displayed on the LCD.
- The rest of the sketch consists of a collection of function used to control the LEDs and the LCD.
A note on persistence...
Some Intel Edison firmware versions have a bug which breaks Arduino sketch persistence. If you find that your Arduino scripts are not automatically being reloaded on reboot, then you’ll need to address this. There is a great thread in the Intel Edison community that addresses this here: https://communities.intel.com/thread/77945