Introduction to Electronics and Arduino Programming
For this project, we’ll be assembling the Vex Eye by Tanner and introducing basic Arduino and electronics concepts along the way.
Here’s a list of the supplies you’ll need to follow along:
- Adafruit Gemma
- Flora NeoPixel
- Wiring (we used 16 gauge)
- 3.7v 150mAh li-ion battery
- Soldering iron and solder
- Cyanoacrylate based super glue
- Sandpaper (high grit to low grit)
Print and Post Process your Parts
To get started, print out the remixed design files for Tanner’s Vex Eye here! This version includes a modified electronics plate to accommodate the Adafruit Gemma and NeoPixel boards. We printed the body in Formlabs Grey Resin, the lenses in Formlabs Clear Resin, and the nubs for the shell in Flexible Resin. Feel free to mix and match with colors as long as a clear material is used for the lenses!
To polish the lens and improve the opacity, we used progressively higher grit sandpaper starting at 200 grit and working our way up to 1600. Mineral oil helps to improve the opacity after sanding is completed. For a more detailed look at polishing clear parts, check out this blog post on creating fully functional camera lenses.
Wire Up the Electronics Hardware
Now that all of our parts are printed, we’re going to get started on wiring up the electronics. For this project, we will use Adafruit’s Gemma and Flora NeoPixel boards. Typically, the Gemma and Flora NeoPixels are used for wearable electronics. We are using them because the small form factor fits well into our Vex Eye model.
Connect ‘V out’ to the positive terminal of your NeoPixel, ‘GND’ to the negative terminal of your NeoPixel, and D1 to the forward facing arrow. You’ll want to make your wires as short as possible so that there is a little space between the lens of your Vex Eye and the NeoPixel board. ‘V out’ and ‘GND’ are providing power to your board while ‘D1’ provides the signal and instructions to the NeoPixel. Below you’ll find an image of a ‘fritzing’ diagram which shows how the board is wired.
Set Up Development Environment
Now that we have everything wired up, we’ll need to setup our development environment. Adafruit’s boards are programmed using the Arduino IDE (standing for Integrated Development Environment) and you can find the latest version here!
Next you’ll need to grab drivers for your NeoPixel boards. Adafruit provides an install package here! Run the installer and make sure that the ‘Arduino Gemma’ option is selected. If you run into a bit of trouble with driver installation, check out Adafruit’s guide which has a few more install options and troubleshooting steps.
We’ve a bit more setup to do for our development environment and next you’ll want to open the Arduino IDE. Navigate to ‘File’ -> ‘Preferences’ and in the ‘Additional Boards Manager URLs’ box enter the following URL: ‘https://adafruit.github.io/arduino-board-index/package_adafruit_index.json’. This will import Adafruit’s boards into the Arduino IDE.
Hit ‘Okay’ and navigate to the ‘Tools’ section. Select the ‘Board’ tab and go to ‘Boards Manager’. Scroll until you see ‘Adafruit AVR Boards’ and hit install! The final step is to go back to the ‘Tools’ section and then navigate to the ‘Programmer’ tab. Make sure this is set to ‘USBtinyISP’.
Program the Gemma Board
Now that your development environment is setup, we can get started on programming the Gemma board. In the Vex Eye design files, you’ll find ‘vexeye.txt’ which we’ll paste into the Arduino IDE. Let’s breakdown what this code does so that you can customize it to your liking.
The first couple of lines tell the Arduino IDE how our Gemma board is wired and imports the necessary libraries. ‘void loop()’ will loop through all of the functions contained within the brackets. Here we have two functions; colorWipe and rainbow.
You’ll notice that there are two slashes ‘//’ in front of colorWipe by default. This is a way of commenting out and disabling code. Rainbow is enabled by default but if you’d like to change this, put two slashes in front of ‘rainbow’ and remove the slashes in front of color loop. If you’re feeling especially adventurous, both functions can be enabled at the same time and each will run for a set amount of time. The run time is determined by the last variable passed to each function (50 for the colorWipe function and 20 for the rainbow function).
The colorWipe function displays red by default but can be customized to whichever color you’d like. The first 3 numbers, specify RGB values. If you want to change the NeoPixel to orange for example, set your function to ‘colorWipe(strip.Color(255, 153, 0), 50);’ for orange.
Upload Your Code
Now that we’ve customized our code, it’s time to upload to the board. For this, we’re going back to the ‘Tools’ tab at the top. Under ‘Board’, make sure ‘Adafruit Gemma 8MHz’ is selected. Also, make sure that the correct Port is selected. If you run into upload errors, one of the first troubleshooting steps is to verify that you’re uploading to the correct port.
Once your sketch is done uploading, you’ll notice that your NeoPixel lights up! If everything is working, plug in the battery to your Gemma board and carefully insert everything into the Vex Eye. Screw the cap to secure everything in place and our project is complete!
While controlling a single NeoPixel doesn’t seem especially impressive, this is the framework that many Arduino projects are built off of! You learned basic electronics wiring, how to add custom Arduino compatible boards, and a bit of programming. The end result is a pretty sweet looking prop.
We’re looking to do more of these tutorial based projects so if there’s something specific you’d like to see, comment below!