NeoPixelControl

The purpose of this app is to control a stripe or shield of Neopixels from the company Adafrui, connected to an Arduino Mega and a WiFi shield. Some other shield (Ethernet) can also be used.

 

Attention: This application is not endorsed or supported by Adafruit, the term NeoPixels used with permission from Adafruit

Hardare you need

 

1. An Arduino Mega. I use a Neopixel stripe with 240 Neopixels, and the memory rquirements just make it impossible to use a type of Arduino with less memory. If you have very few Neopixels, say 8 or 16, you could try, at your own risk!, to control them with a different type of Arduino. But I strongly advise against it.

2. Of course, you will need Neopixels from Adafruit. Visit their pages, they have many different kinds.

3. You need some way to communicate from your Android device to the Arduino. I used the CC3000 Wifi Shield from Adafruit, but you can use any other shield, as long as it is compatible with the aRest library. See below..

4. You will need a power supply for the Arduino and the Neopixels. The current requirements of Neopixels are described on the pages of Adafruit. In my case, I have 240 Neopixels, I have a 16A power supply.

5. You will need an Android device running at least version 4.4 of Android.

 

Software you need

 

Of course, you need the Arduino IDE, at least version 1.6.3, to be found at Arduino.org. And you need to know how to use it, how to install additional libs, how to edit a sketch (that's what programs for the Arduino are called), and how to tranfer sketches from the IDE to the Arduino.

You will need the Neopixel library from Adafruit. Instructions and a dowload link can be found at https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library

The aRest library, download at https://github.com/marcoschwartz/aREST. This lib can handle many different ways of communication using shields from many manufacturers. For further details, and to find out, if your shield is supported, read the file aRest.h Since NeoPixControl uses aRest, you need to have hardware that aRest supports.

In my case, I used the CC3000 WiFi shield from Adafruit, so I downloaded the library for it, from https://github.com/adafruit/Adafruit_CC3000_Library

 

And lastly, you need my sketch that puts it all together, you can download it here.

 

After you have set up and installed all the needed libs, load my sketch NeopixelControl.ino. You will need to make some changed before uploading it to your Arduino Mega.

 

1) Line 7 reads:

#define STRIPLAENGE 40 // number o neopixels in your stripe

replace the number 40 with the number of neopixels in your stripe

2) Line 13 reads:

#define PIN 33 // arduino pin connected to your stripe

replace the number 33 with the number of the output-pin on your Arduino board that the neopixel stripe is connected to

 

3)

Lines 40 - 46 read

// Your WiFi SSID and password
#define WLAN_SSID "your ssid"
#define WLAN_PASS "your password"
#define WLAN_SECURITY WLAN_SEC_WPA2

 

This is for the CC3000 WiFi shield only. Put in the SSID and password of your router. If you dont use the CC3000 consult the documentation of your shield how to set it up.

 

After this is done, save the sketch and then transfer it to your Arduino Mega.

Just in case: to make sure, your hardware is working, the Neopixel lib and the Wifi lib and also the aRest lib all contain some example sketches. Before you transfer the Neopixel sketch, it might be an excellent idea to test all those libs separately using the examples supplied with the libs, and make sure they all work.

 

Limitations: The App is not synchronized to the Arduino. That means, the app knows nothing about what the Arduino is doing, what pattern it is displaying at the moment or what effects are running. So it may happen, that the Arduino is running an  effect in backwars direction at the time you start the app. But on the movement effects screen of the app the choice "forward" is selected.

 

NeoPixControl - App

First, if you have not done so, install the Android App from Google Play. It requires an Android device running at least version 4.4 of Android. Next, you need to change some setting.

 

settings

Enter the numer of Neopixels in your stripe. Next, enter the maximum number of Neopixel brightness values to be sent in one step. I will explain that: If you have, like me, 240 Neopixels you will notice, that it is not possible to transmit the brightness values of all of them at once to the Arduino. The reason is memory and buffer limitations. I found in my case, that I can transfer the values for 80 Neopixels only. so, to transfer the values for all 240 pixels I need 3 transfers. That takes more time, but it works. If I try it with more pixels at once, the Arduino might hang (requiring a reset) or behaves erratically. And, lastly, enter the adress of the Arduino, so the app will know where to send the data. Dont forget the "http://" part in front.

 

Navigation

 

If you touch on the upper left, you will see the navigation screen

 

navigation

One Color

The first choice "All one Color" leads to this screen:

onecolor

In the color selector touch on the desired color, with the brightness arrow at the right side select the desired brightness, then press "transmit". Your whole stripe should light up in the selected color now.

 

One Gradient

The second choice, "All one Gradient" leads to this screen:

onegradient

Here you can set a starting color and an end color of a color gradient. You can choose the type of Gradient: HSV, rHSV and RGB. The App will calculate the color values of all LEDs in the stripe and transmit them. You will see a color gradient on your stripe.

 

Pattern Editor

 

The next item in the list is "Pattern Editor". It looks like this:

patternedit

A pattern contains one or more pattern segments. Each segment has a length and a color. You enter the lenght in the input field, you determine the color by selecting a color and brightness on the color circle AND pressing "set color"!! You can create new segments at the end by pressing "add", you can insert a segment by pressing "insert". The current segment will then be pushed to the right. You can delete a segment by setting it's length to zero, before saving or transmitting it will then be removed (not right away!). You can delete the whole pattern by pressing "Delete". You can Save and Load patterns.  The checkbox "repeat pattern" when checked, will cause your pattern to be repeated until the whole Stripe is filled.

You can make the segment a color gradient by setting a start and an end color. Setting a start color will set the start and end color the same, so you will not have a gradient. Only ba setting an end color - it must be different than the start color, will you have a gradient. Gradients of length 1 make no sense, so make the segment longer.

 

Effect: Move

 

The next choice brings this to the screen:

effmove

You can make a pattern, or whatever is on the stripe, move. The bar at the bottom selects the speed. You can choose to move forward, backward or alternating. When selecting alternating, you have 2 choices for the condition when the movement reverses. a) at the end. After moving the length of your stripe, the direction woll be reversed. Example: Your pattern is just one lone red led at the first position, not repeated. By selecting this option, the red dot will appear to move back and forth between the ends of the stripe. If your stripe is 60 neopixels long, the movement will reverse after 59 steps. So the number of steps hould be 59. If your pattern has a length of 2 pixels, the number of steps should be 58. And so on. Of course, you can enter eny numer you like. b) Timed reversal. If you select this option you can enter a time in seconds, and the movement will be reversed whenever the time is over. Example: You enter 5, then the pattern will move forward for 5 seconds, then backwards for 5 seconds, then again forward for 5 seconds, and so on.

 

Effect Color Change

effcolorchange

The color change effect makes the whole strip one color, and that color will change. How it changes will be controlled by a pattern. So you must first design and save a pattern with the pattern editor. Press "Load" to select and load a pattern. Press Transmit to send it to the Arduino. You see nothing? Select a spped larger than 0 with the bar at the bottom, and the colors of the pattern will be shown one after the other. Remember, a pattern can contain one ore more color gradients, so the color changes can be as smooth as you want them.

Effect Brightness

This screen allows us to have the brightness change with time.

effbrightness

Here you can set the minimal brightness, the maximal brightness and the speed of the brightness change. Below that you can determine the color component that is affected by the brightness change. By default 'All' is selected. All colors change by the sam amount, the whole pattern will dim and brighten. But it is also interesting to select only one component, R (red), G (green) or B (blue) for the brightness change. A simple example will explain why.

Suppose you have the whole stripe set to orange. Orange is made from a lot of red and a little bit of green. I you now select R for the color change, the red component will decrease. That makes the stripe color change from orange to yellow and finally to green. And back again. On the other hand, if you select G, the color of the stripe will change from orange to red and back to orange. And now imagine a stripe with a more complicated pattern with many colors. By applying the brightness change to one component only, you can make some pixels in the stripe change colors, others not.

 

Command Recorder

 

With the command recorder you can record, save, load and play back the commands that were transmitted to the Arduino. NOT the commands and touches on the Android device. (That is a significant difference!)

commandrecorder

The operation is straight forward: Press 'Start Recording', then use the app in any way you want to send patterns, gradients, effects etc. to the Arduino. Then coma back to this screen and press 'Stop Recording'. You can save the recorded commands to your devices storage by pressing 'Save' or load them by pressing 'Load'. If there are recorded commands, either by recording or loading, you press 'Play' to send them (again) to the Arduino. 'Play' woll send the commands to the Arduino as fast as possible, while 'Play Realtime' will send them to the Arduino as fast as you entered them. If you check 'repeat' the list of commands will be repeated whenever it reaches the end. When playing you will see a progress dialog like this:

playdialog

You can stop playing at any time by pressing 'Stop playing'.If you have not checked 'repeat' play will stop automatically when the end of the command list is reached, but if you have checked 'repeat', then it will not. You have no choice but to press 'Stop playing'.

 

 

Gradients explained

 

Gradients have a start color and an end color. They show the start and end color and all the color in between. But which colors are in between? That depends on the type of gradient. In this app we use only 3 types, named HSV, rHSV and RGB. Look at the (clumsily hand drawn) graphic below.

 

 

 

gradients

You see a start color (somewhat redish), an end color (somewhat blueish) a 0-line, and several paths between start and end.

RGB. The RGB path is the simplest, but it comes close to the white center of the circle, where colors are somewhat whashed out.

HSV: it follows a circular path. As you see on the diagram, there are 2 circular paths, the white one and the violet one. HSV always takes the path that does not cross the 0-line.

rHSV: Similar to HSV, the path is also circular, but it ALWAYS crosses the 0-line.

If you dont know which gradient to use, simply try them all and keep the one you like best. Tip: For the color change effect you will sometimes wish for the colors to come all the way around to the start color. You can achieve that by making a pattern with a long gradient, where the start and end colors are very close to each other (almost the same) and make the gradient type rHSV, so it will likely take the long way all around the color circle.

 

Final Note

If you have any ideas or suggestions on how to improve this app, if found problems or bugs: send me a mail to neopixcontrol@aschenbrenner.com

As you may have noticed, English is not my native language. If you find any typos or idiomatically bad expressions, please let me know.