Eye of newt, and toe of frog,
Wool of bat, and tongue of dog,
Adder's fork, and blind-worm's sting,
Lizard's leg, and howlet's wing,--
For a charm of powerful trouble,
Like a hell-broth boil and bubble.

This guide is based on the Uncanny Eyes project by Phil Burgess, with a Halloween-y twist.  We'll build an electronic eye as compact and small as possible.  Put it in a wide-mouthed jar and add it to your potion shelf, or attach a leather thong to wear it like a pendant around your neck.  

This is a fairly advanced project that requires fiddly soldering in a small space and uses delicate parts.  There's a good bit of software setup needed also.  You can add custom images and tweak the code if you'd like, or just copy and paste our code as-is.  It's not an easy project, but the end result is so incredibly cool that it's worth a bit of hard work!

Parts

1 x Teensy 3.2
Teensy 3.1 or 3.2 Microcontroller
1 x OLED Display
OLED Breakout Board 16 Bit Display
1 x Photo Cell
Photo cell CdS Photoreistor
1 x Battery Charger
LiPoly Backpack Battery Charger
1 x Battery
500 mAh LiPoly Battery
1 x 10k Resistor
10k Resistor
1 x On/Off Switch
SPDT Slide Switch

Other Stuff Needed

  • Hookup wire in 2 types / multiple colors:
    • Solid core wire 
    • Silicone stranded wire
  • Soldering iron & accessories
  • Hot glue gun
  • Reptile print or halloween fabric
  • Wide mouth jar or necklace cord
  • 1.5" acrylic half-sphere (less expensive at your local Tap Plastics)
  • Needle & thread

Before you start soldering, get all your software running and uploaded to your Teensy microcontroller.  Getting the code loaded up first will make it easier to troubleshoot any soldering or build issues later on.  

Software setup is fully covered in the Uncanny Eyes project here.  Make sure you have installed everything listed below before moving on.

  • Arduino IDE
  • Teensyduino Installer 
  • Libraries (installed via the Arduino IDE and NOT the Teensyduino installer):
    • Adafruit_GFX
    • Adafruit_BusIO
    • Adafruit_SSD1351
    • Adafruit_ST7735
  • Python PIL Library (only if you want to add your own custom images)

Once all that is installed, download and open the sketch. 

Select 72 MHz as your CPU speed…it’s actually smoother than 96 KHz for this particular code.

Code Download

The code will download as a .zip file.  Inside you'll find a folder called "convert" that contains several different image folders and a python script, and another folder called "uncannyEyes" that contains the Arduino sketch.  Start by uploading the code as-is, for testing purposes.  Make sure it works before making changes.

Look at the config.h file.  Right at the top you'll find several different eye options.  Uncomment the #include "newtEye.h" line to turn on the newt eye option, and comment out the #include "defaultEye.h" line. There can be only one!

// Enable ONE of these #includes -- HUGE graphics tables for various eyes:
//#include "graphics/defaultEye.h"  // Standard human-ish hazel eye -OR-
//#include "graphics/dragonEye.h"   // Slit pupil fiery dragon/demon eye -OR-
//#include "graphics/noScleraEye.h" // Large iris, no sclera -OR-
//#include "graphics/goatEye.h"     // Horizontal pupil goat/Krampus eye -OR-
#include "graphics/newtEye.h"       // Eye of newt

This code defaults to rendering to two eyes.  Since we only have one eye, we can turn off the second one to make the code run faster.  Just a few lines down, look for the eyeInfo[] array and comment out the last item within:

eyeInfo_t eyeInfo[] = {
#ifdef ADAFRUIT_HALLOWING
  { 39, -1, 2 }, // SINGLE EYE display-select and wink pins, rotate 180
#else
  {  9, 0, 0 }, // LEFT EYE display-select and wink pins, no rotation
//{ 10, 2, 0 }, // RIGHT EYE display-select and wink pins, no rotation
#endif
};

Customizing the Graphics

I wanted to make an eyeball that looked as much like a real newt's eye as possible.  I did an image search and found one I liked.

I used photoshop to "unroll" the eyeball so the software can draw it correctly.  After some cropping, zooming, and judicious use of the "Liquify" tool, here's what I ended up with.

The sclera (the white part of the eye) on a human looks really different from a reptilian eye.  I wanted a more newt-like look, so I inverted the colors in Photoshop, then added a black circle to the center to keep the pupil dark.

It took me several tries to get it right, but I'm really happy with the end result.  These images are included with the code download, and the process is explained thoroughly over at the Uncanny Eyes guide.  Go nuts and create your own unique look.

Eye Orientation

There's one more change we can make in the code to change the orientation of the image.  If your build comes out sideways or upside-down, and you want to rotate the eye to compensate, look for this line in the code, in the eyeInfo[] array:

  {  9, 0, 0 }, // LEFT EYE display-select and wink pins, no rotation

To rotate the eye 90 degrees clockwise, change the last “0” to a “1.” To rotate 180 degrees, use “2,” and for 90 degrees counterclockwise use “3.”

I personally like this eye rotated 180 degrees to upside-down from the original image.  I think It makes the eye look like it's up to something crafty, which is really what I'm looking for in my Eye of Newt.

Troubleshooting

If you're having trouble, head over to the Uncanny Eyes guide and take a look at some of the troubleshooting ideas.

There are a lot of connections that need to be made.  Using a combination of solid core wire and stranded wire is the easiest way to get everything packed into as small a footprint as possible.  

Color coding is your friend here!  Keep your power wires all red and ground wires all black, and use a variety of colors for the other connections so you don't get confused.  Write down the colors you used and the corresponding pins they connect with so you have a quick reference you can use while soldering.

 

Teensy 3.1

OLED

Backpack Charger

Vin

+

BAT

G

G

G

USB

5V

7

DC

8

Reset

9

OC

11

SI

13

CL

16

Resistor + Photo Cell

3.3V

Resistor

G

Photo Cell

Prep your Charger

  1. Bridge the charge pad on the back with a blob of solder, to make your battery charge faster
  2. Cut the trace between the switch pads on the front to enable your on/off switch.

Prep your Switch

Trim the switch legs to about half their length.  Solder a 4" wire to the middle leg and to one of the side legs, and cut off the other side leg.  Secure the connections with heat shrink.

Solder the two switch wires into the switch pads on the charger.

Prep your Photo Cell Sensor

Trim your photo cell's legs to about 1/3 of their length.  Solder a stranded black wire to one leg, and two stranded colored wires to the other leg.  (The legs are interchangeable so it doesn't matter which is which.)  Cover each connection with heat shrink, then cover the whole photo cell with larger heat shrink, leaving the top visible and uncovered.

Prep your Teensy & Display

Cut the trace between the USB charging pads on the back of the Teensy.

 

Place a large piece of thick tape (gaffer's tape or duct tape works great) over the back of the OLED display, carefully covering all the exposed components but leaving the solder hole labels visible.

Solder Power Wires & Charger

Using silicone stranded wire, solder two red wires into VIN and two black wires into G on your Teensy.  

 

We're using silicone stranded wire here because the solid core wires won't fit two-to-a-hole.

Set the charger next to the Teensy and solder a solid core wire from Teensy's USB pin to the charger's 5V pin.

 

Solder one of the stranded red wires to BAT and one of the stranded black wires to G.

Attach Display Wires & Photo Cell

Solder various colors of solid core wires to Teensy's pin 7, 8, 9, 11, and 13.  We'll trim these to length later, for now just be sure they're at least a couple inches long.

Trim one leg of your resistor down and solder it into the 3.3V pin on the Teensy.  Solder the other leg to one of the wires coming from your Photo cell sensor.  Cover the whole resistor with heat shrink.

Solder the other colored wire from the Photo cell into Teensy's pin 16, and the black wire into the GND pin next to the Teensy's reset button.

Place the Teensy and charger in line with the back of the OLED display as shown.  Carefully trim and solder all the remaining wires to the OLED display.

 

 

Plug your battery in and slide it between the OLED display and the rest of the components.  Wind the wire around and bend the solid core wires until you have a tidy package.  Secure everything in place with a few judicious blobs of hot glue.

Flip your switch on and watch your eye dance around!  Cover the photo cell to watch the pupil dilate.  (Photo cell not shown in this image)

Cut a small piece of fabric about 8"x8".   Place your cabochon in the middle and trace around it on the wrong side of the fabric.  Cut a hole for the cabochon that's a little smaller than your mark so the cabochon won't fall through.

Fold your fabric in half around your electronic eye and mark where it meets itself.  Sew the raw edges together with the right sides facing inwards.

Flatten the fabric so the hole is on top and the seam is at the center back.  Stitch a curved edge about 1 inch below the hole.  Make sure the electronics fit nicely inside.

Place your cabochon into the hole, face down (so you're looking at the flat side).  Run a bead of glue all around the edges to hold it securely in place.

Turn your case right side out and gently slide the electronics inside with the switch and photo cell coming out the open top.  With a utility knife, make a small slit above the USB port.  Make another hole for the photo cell sensor to poke through.

Sew up the top of the case with a needle and thread, leaving the on/off switch accessible.  I finished by coloring my on/off switch with a paint pen so it blends in better with my case.

Finish up by attaching a necklace cord, or leave it as-is and keep it safe inside a potion jar. 

Remember that the OLED screen is really delicate, so do NOT try and squeeze it into a jar that's a tight fit -- you can break the screen if you squeeze it too hard.

Charge it up by plugging in a USB cable -- the indicator light on the charger will turn green when it's fully charged.

This guide was first published on Oct 19, 2017. It was last updated on Oct 19, 2017.