RGBW NeoPixel ring works with the Particle Photon

I tried hard to make an RGB NeoPixel ring with the Particle Photon, but never manage to do it. So I ordered the new RGBW NeoPixel ring and now it works really fine. It even work without the logic converter in fact. Here my demo and the code.

// Set pixel COUNT, PIN and TYPE
#define PIXEL_COUNT 16
#define PIXEL_PIN D2

// Adafruit NeoPixel library found in the Particle.io IDE.
#include <neopixel.h>

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

void setup() {
    strip.setBrightness(10); // Brightness 0-255
    strip.show(); // Initialize all pixels to 'Off'


void loop() {

void testAll() {
    for(uint16_t i=0; i<strip.numPixels(); i++) {

An automated green thumb in the garden

My wife and I love eating fresh food. Fresh cut herbs cost as much as the whole living plant. So we start buying these fellows in their pot. However, in the winter the days are too short, they won’t grow. So I decided to build a lightened garden to give them what they need. In fact, it is not a new idea, I plan to build a computer controlled garden for a while.

I need  to start somewhere and develop my gardening skills and understand how to automate the thing. This first project is much like a prototype. I gather some junk I accumulated around the house, and I build this little oasis.

Smart garden without electronics

The reflectors

I begin with the reflectors. I build them from old floor heater front panels. I cover them with aluminum foil. They are not wide enough to cover the entire light. So when we sit we can see the direct light. However, they do the trick.

Reflector build with aluminum foil

Reflectors assembly

Here is the complete assembly of the garden, before the paint. Before I start, I already know that my light was too high. In the next one, it will be adjustable. When I built it, I had no clue of the height of the plants I will grow in it.

Fluorescent lightening

I use two 45 watts fluorescent bulbs I pick from my studio box. They are full spectrum 5500k lights. I use it for two weeks now, and the plant seem to have enough light. In my readings, I found that the best temperature is 6400k. I plan to purchase some real fluorescent tube grow lights after the holidays.

Smart garden assembly before paint

The moisture sensors

These bolts will be the moisture sensors. I gravelled about two inches of the bottom of the planter. The bottom sensor will tell if they are too much water. The side sensor will keep track of the soil moisture. Both will be hooked to and Arduino. I hope it will work! I had not tested yet.

Moisture sensors

Moisture sensor head

The controller

This is it for now. The next part is where the fun begins. For me at least! I can not do things the simple way. So I want this garden as automated as possible. Here’s a sneak peak.

Smart garden diagram

Arduino data logger and humidity temperature moisture sensors

Blink a led with style

Basically, when we want to make a LED blink with an Arduino, the program will stick in a loop and hang on delays. Imagine if we want this LED to fade in and out. The program could take all the process time to do it, and the processor won’t be able to do something else. So I imagined a little piece of code that work like this: a list of commands is sent to the program and the LED will turn OFF and ON following these commands. The list of commands is executed, but he program can continue polling other methods. When the program has nothing else to do, it goes back blinking the LED. The timing is respected, but the number of steps to go from the start point to the stop point may vary when the micro-controller is busy doing something else.

The following steps explains how to use the program.

First, list the commands you want the LED do

Create an array containing the scheme that will be played by LED. Each row of this array contains four parameters:

    1. Start brightness;
    2. Stop brightness;
    3. Duration;
    4. Easying (not yet implemented).

The array look like this:

const int commandCount = 4;
int commands[commandCount][4] = {
    {0,255,1000,0}, // 1st command: Start with the LED off then go to full brightness progressively in 1 second.
    {255,255,5000,0}, // 2nd command: Keep the LED at full brightness for 5 seconds.
    {255,0,1000,0}, // 3rd command: Turn the LED off progressively in 1 second.
    {0,0,3000,0} // 4th command: Keep the LED off for 3 seconds.

Second, declare your LED

LED myled (LED_PIN, &commands[0][0], commandCount);
  • The first argument is the pin number where the LED is connected.
  • The second argument is the address of the first item of the array.
  • The third argument is the number of commands.

Finally, call the LED loop method in the Arduino loop method

void loop() {

You can also declare multiple LEDs. They will blink together accordingly to the timing you set.

You can get the source code on my Git account.

Marvin let me drive easily

In this second version of the software, I managed to be able to slide my thumb to the OSC controls. I explain. When you move an OSC slider, a bunch of commands are sent. Not just the start position and the end position, but many position behind these last two. On the Marvin robot, the commands are received and computed by the Raspberry Pi then send to the Arduino board through the serial port. The problem is at this point. The serial command are very slow, and there are queued. So when I moved my thumbs to accelerate it take a while to the robot to get to the speed. Worse, when I hit the panic break button, it has the queue all the commands sent before.

So I manage to put all the commands in a list. Them only send the last one when the serial port is ready. Look a bit easy, but I had to learn a bit more of Python and understand how to create threads. The fun thing? I had fun doing it : )

Use TouchOsc on the iPhone to trigger something on the Raspberry Pi

I can now use TouchOsc on my iPhone to trigger something on my Raspberry Pi. I use the Python library pyOSC to do it. It works practically out of the box. The difficulty was to install the Python library. I’m not so familiar with installing things on linux. For now,  I can send from my iPhone, but today I plan to get it working both ways. I invite you to follow Playwithmyled.com on Twitter to get posted about my progress.

Raspberry Pi Touch Osc iPhone