It started about two weeks ago in Hackster HQ with an inexperienced intern (me), an awesome mentor (Ben Larralde), and some great coworkers (namely Alex Glow). My passion is building electric skateboards, and Ben and Alex found a way to tie that together with coding by providing me with an Arduino and some NeoPixels and letting me have my fun while learning how to code. This project is the result of that. I believe it turned out well, and so I am now sharing it with the community.
Part 1: Tools/Experience NeededObviously there's a parts list below, but I think a run through of what you really need and why you need it might help. Essentially, the important stuff to have here is really the NeoPixels and some Arduino-type system. I started with the Arduino Uno and moved to the Teensy 3.2, but pretty much anything will work. The smaller it is, the less weight to worry about (since for me this was on the bottom of a skateboard). You'll need basic breadboard knowledge and some decent soldering skills since the pins tend to be pretty small. Additionally, I recommend owning an electric skateboard. Obviously this project applies to much more than just electric skateboards, but having one is fun and you'll be able to use this guide in a much more specific application if you do.
So, assuming that you have all of the parts needed, or have at least ordered them, you can get started with setup. First, figure out how many NeoPixels you want and where you want them on your deck. Some people like it on top, but I decided to use 21 pixels per strip, 2 strips, towards the back of the deck. That way when I accelerate it looks extracool. Get everything laid out, connected first, and placed where you want it on your deck. Don't solder to the Arduino (or Arduino variant) yet, just solder one end of jumper cables to the tabs on the NeoPixel strip (5V, Ground, and Data), and use a breadboard during the programming process (you'll thank me later). Once you've got that all set up, connect your Arduino to your computer. We'll program first, and then power the unit off of the skateboard battery later.
I am no expert in coding, and I started learning when I started this project. So, I mainly modified Alex Glow's wonderful tutorial and used that to control these NeoPixels. The easiest way to get this running for you would be to copy and paste, modify it using the different strings (which control the individual NeoPixels), and change the RGB values to whatever you want them to be. You can also modify the delay value to change how fast or slow you want the NeoPixels to "move". When uploaded, test it out and make sure you like your pattern before moving on.
#include <Adafruit_NeoPixel.h> //Make sure to include the Adafruit library in order to enable controlling of the Neopixels
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 12 //This is where the data line of your Neopixels will connect to. It can be any number pin really, I just chose 12.
#define NUMPIXELS 21 //This is where we determine the number of pixels. I am only using 21 for each strip on the actual skateboard, so that's what I chose.
#define STRING_LENGTH0 21 //If you want to be able to control individual pixels in a "moving" string of neopixels, making different stringlengths from the maximum down to 1 is important.
#define STRING_LENGTH 20
#define STRING_LENGTH2 19
#define STRING_LENGTH3 18
#define STRING_LENGTH4 17
#define STRING_LENGTH5 16
#define STRING_LENGTH6 15
#define STRING_LENGTH7 14
#define STRING_LENGTH8 13
#define STRING_LENGTH9 12
#define STRING_LENGTH10 10
#define STRING_LENGTH11 9
#define STRING_LENGTH12 8
#define STRING_LENGTH13 7
#define STRING_LENGTH14 6
#define STRING_LENGTH15 5
#define STRING_LENGTH16 4
#define STRING_LENGTH17 3
#define STRING_LENGTH18 2
#define STRING_LENGTH19 1
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 5000/100; //100 = 1 second, and this will control how "fast" your string of Neopixels "moves"
void setup() {
pixels.begin();
}
void loop() {
int i=0;
while(true) {
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i-STRING_LENGTH, pixels.Color(255,0,0));
pixels.setPixelColor(i-STRING_LENGTH2, pixels.Color(240,0,0));
pixels.setPixelColor(i-STRING_LENGTH3, pixels.Color(250,110,0));
pixels.setPixelColor(i-STRING_LENGTH4, pixels.Color(255,165,0));
pixels.setPixelColor(i-STRING_LENGTH5, pixels.Color(255,190,0));
pixels.setPixelColor(i-STRING_LENGTH6, pixels.Color(255,220,0));
pixels.setPixelColor(i-STRING_LENGTH7, pixels.Color(255,255,0));
pixels.setPixelColor(i-STRING_LENGTH8, pixels.Color(150,210,0));
pixels.setPixelColor(i-STRING_LENGTH9, pixels.Color(90,170,0));
pixels.setPixelColor(i-STRING_LENGTH10, pixels.Color(0,128,0));
pixels.setPixelColor(i-STRING_LENGTH11, pixels.Color(0,70,90));
pixels.setPixelColor(i-STRING_LENGTH12, pixels.Color(0,30,175));
pixels.setPixelColor(i-STRING_LENGTH13, pixels.Color(0,0,255));
pixels.setPixelColor(i-STRING_LENGTH14, pixels.Color(25,0,200));
pixels.setPixelColor(i-STRING_LENGTH15, pixels.Color(50,0,170));
pixels.setPixelColor(i-STRING_LENGTH16, pixels.Color(75,0,120));
pixels.setPixelColor(i-STRING_LENGTH17, pixels.Color(130,40,160));
pixels.setPixelColor(i-STRING_LENGTH18, pixels.Color(190,85,100));
pixels.setPixelColor(i-STRING_LENGTH19, pixels.Color(238,20,20));
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval);
i = (i+1) % (NUMPIXELS + STRING_LENGTH);
}
}
At this point in the project, after finishing the coding and layout with the Arduino Uno, I moved to the Teensy 3.2 because it is smaller and much easier to fit on the bottom of my board. It was easy to move everything over using the reference diagram that came with the Teensy, but the one thing to remember is that if using an external power source, it must be powered through separate Ground and 5V pins, not a hacked microusb cable. Getting the code to work is super easy, just download the Teensy attachment and run it alongside the Arduino software to connect.
For the actual power side of things, I got ahold of a 24V to 5V buck converter, and wired that straight into the battery output of the board. From there, it's easy to connect the 5V output side to the 5V input and Ground of the Teensy. Again, be sure to connect this in the right place for it to power up. This is where we start soldering, and I recommend using XT90 connectors to make everything nice and modular. I also glued the buck converter to the bottom of my speed controller enclosure and the NeoPixels to the bottom of the board at this point, since they weren't going to be moving anymore.
In order to power both NeoPixel strips at the same time, I used different 3V and Ground pins available on the Teensy. The only pin that needs to be connected to both of the strips is pin 12, since that can't be replicated. Be mindful when soldering this, because although possible to wire the 3V and Ground pins in parallel for both strips, the pins are extremely small and I found it beneficial to keep them separate.
Once those are all soldered up, I held it all together in one bundle with zip ties and went out riding! When the board is turned on, so are the NeoPixels. It would also be pretty easy to put in a switch if I wanted, but showing off is more fun in my book.
Everything else on this skateboard is waterproof (believe it or not), so I want to make sure that riding through the rain won't hurt it too much. I 3D-printed an enclosure which can be easily sealed with hot glue, but which also has nice openings for the wires protruding in 3 areas. There is a hook that allows easy connection with zip ties as well.
Comments