The eyeball code we'll use is from the Electronic Animated Eyes project, a.k.a., 'Uncanny Eyes', with a couple of small tweaks.
First, get set up with Arduino IDE as detailed here.
Next, follow these instructions on getting the proper libraries installed for the Adafruit_GFX and Adafruit_ST7735. Note, we aren't using the Teensy, so don't pick that board from the list. While you're in the Arduino Library Manager (Sketch→Include Library→Manage Libraries…): also install Adafruit_ZeroDMA.
Once you've updated the board definitions as shown, you'll be able to select Adafruit HalloWing M0 Express as your board for compiling and uploading.
Before you continue, make sure you can plug in your HalloWing over USB and upload the Blink sketch found in Arduino IDE menu Examples > 01.Basics > Blink
If everything is set up properly, the HalloWing should now be blinking the onboard LED every second.
All-Seeing Skull Sketch
The code used on the HalloWing for the All-Seeing Skull along with the graphics is in the Adafruit GitHub repository.
Inside that folder, find the All_Seeing_Skull folder and move them into your Arduino sketch directory.
Inside of Arduino IDE, open up the All_Seeing_Skull.ino sketch.
Upload the sketch to your HalloWing and you will see the eye open and look around! After a few seconds, if the PIR sensor doesn't detect movement, the eye will close. If you (or any largish, warmblooded creature) move a slight amount, the sensor will trigger again.
Also note, the pupil will dilate or contract depending on how much light it detects. The sensor for this is on the HalloWing, but will still react, even inside the skull, to changes in ambient light. Especially effective if someone shines a flashlight on the All-Seeing Skull!
Configuration
A few small changes have been made to the code based on the original Uncanny Eyes project to accommodate the HalloWing and lens being inside the skull's eye socket.
The full range of motion for the original eye was a bit large and would cause the eye to look inside the socket and disappear from view a bit (this may be the effect you want!) so, in the config.h file that accompanies the Arduino sketch, we made these additions:
//Adjust these offsets and ranges if inside a mask or skull eye socket #define eyeXOffset -150 // aim offset on x for autonomous move, default 0 #define eyeYOffset 300 // aim offset on y, default 0 #define eyeXRange 300 // Range of motion on x, full range is 1023 #define eyeYRange 300 // Range of motion on y, full range is 1023
Here, you can tune the left-right (x axis) with eyeXRange
and up-down (y axis) range with eyeYRange
. The defaults are 1024, I have restricted them to a smaller 300, but feel free to play around with these values and re-upload the code to your HalloWing to test.
Additionally, the point of interest for the eye's "center" of focus can be offset with eyeXOffset
and eyeYOffset
. You can use this to hint the eye gaze center point up or down if the skull is mounted low or high, and toward a cross-eyed or wall-eyed position depending on skull orientation. The defaults are 0 for both.
Customization
You can refer to this page if you want to pick one of the other pre-made looks for the eye. If you want to create your own graphics, this is the page you're looking for.
Page last edited January 22, 2025
Text editor powered by tinymce.