Maker.io main logo

Matrix Portal Jack-o-lantern

2020-10-29 | By Nate_Larson

License: General Public License

Halloween is a great opportunity to get creative. It is the one holiday where the possibilities are endless with very few guidelines. Whether you prefer a campy approach to delight the children, or a more ghoulish atmosphere to scare and excite those of a hardier constitution, Halloween is a chance to let your imagination run free. And while some may be content searching for the elusive 12ft skeleton with animated eyes from their local big box home improvement store, many of us like to take this opportunity to show off our skills with some custom creations.

(BTW, if you have a skeleton or skull with static eyes that you are looking to add some flair to, check out Adafruit’s Hallowing or Monster M4sk.)

This year we decided to add our spin to a classic from the before times, the infamous KXVO “Pumpkin Dance”, but of course, in homage to this cornerstone of modern Halloween internet virality, we needed to add some electronic panache. Cue the Adafruit Matrix Portal.

Matrix-Portal-M4

(Image Source: Adafruit)

The Matrix Portal is a CircuitPython and Arduino compatible ATSAMD M4 microcontroller board designed to plug directly onto any HUB-75 compliant LED matrix. The board also features an ESP32 module providing Wi-Fi connectivity making for a quick and easy solderless connected display.

Adafruit-Matrix-Portal-CircuitPython

(Image source: Adafruit)

For this build, we utilized two of the Matrix Portal boards, two of the 1528-2094-ND 64x32 LED matrices, and one pushbutton from the 1528-4431-ND STEMMA Wired Tactile Push-Button Pack, along with some assorted lengths of wire. Essentially, the build is two independent systems, the first consisting of just the Matrix Portal and LED matrix and following Adafruit’s Matrix Portal Creature Eyes learn guide by Phillip Burgess.

The eyes were modified from the werewolf example with changes made to the stencil, eyes, and upper and lower lid bitmaps, along with some adjustments to the data.py file to accommodate the new shapes. The eyes and mouth are going to be diffused through the thin orange plastic of our pumpkin, so only the whites of the eyes and open mouth should appear illuminated to correspond to the look of a lighted jack-o-lantern. All other regions of the display were adjusted to black.

jack-o-lantern-mouth

The mouth was created by modifying the Halloween Countdown Display Matrix learn guide by John Park. Simplifying it down to a very basic stop motion animation that cycles through four frames from a closed to open mouth when a button is pressed, and back again when the button is released.

Copy Code
import time
import board
from adafruit_matrixportal.matrixportal import Matrix Portal
from digitalio import DigitalInOut, Direction, Pull

mouth = DigitalInOu(board.BUTTON_UP)
mouth.direction = Direction.INPUT
mouth.pull = Pull.UP

FRAME_DURATION = 0.05
FRAMES = (
“bmps/jack_closed_black.bmp”,
“bmps/jack_narrow_black.bmp”,
“bmps/jack_mid_black.bmp”,
“bmps/jack_wide_black.bmp”,
)

# --- Display setup ---
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True

current_frame=0

while True:
while not mouth.value:
If current_frame< 3:
Matrixportal.set_background(FRAMES[current_frame])
time.sleep(FRAME_DURATION)
current_frame + = 1
else:
matrixportal.set_background (FRAMES[current_frame])
while mouth.value:
if current_frame > 0:
matrixportal.set_background (FRAMES[current_frame])
time.sleep(FRAME_DURATION)
current_frame -= 1
else:
matrixportal.set_background (FRAMES[current_frame])

The code above makes use of the onboard “UP” button to activate the animation, but later this was changed to pin A4 and the Pull.UP statement removed when a handheld pushbutton was added, allowing our masked pumkineer to easily actuate the mouth to the sound while wearing the jack-o-lantern. Check out the video below to see the completed project in action and share your Halloween creations with us on social media using #MakeWithDigiKey.

 

 

制造商零件编号 2279
64X32 RGB LED MATRIX - 3MM PITCH
Adafruit Industries LLC
制造商零件编号 4431
STEMMA TACTILE PUSH-BUTTON 5PACK
Adafruit Industries LLC
制造商零件编号 4745
ADAFRUIT MATRIX PORTAL - CIRCUIT
Adafruit Industries LLC
制造商零件编号 4343
MONSTER M4SK - TWO EYES ARE BETT
Adafruit Industries LLC
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum