wolfgang ziegler


„make stuff and blog about it“

Happy Halloween - Raspberry Pi Pico LCD Spooky Eye

October 31, 2022

Each year around Halloween these spooky eye projects keep popping up in my timelines. There are all kind of really fancy hardware (e.g. circular displays) and software (e.g. motion tracking eye movements) solutions out there for these projects. However, I decided to do a spontaneous quick build with what I had lying around.

Luckily, I have a couple of spare Raspberry Pi Picos (a rare luxury these days, I heard) and this Waveshare 1.8 inch LCD for the Pico. I had not find a good application for this display yet, so this was the perfect opportunity.

As it turned out, it only took a few steps to turn this display into a spooky eye project.

Install MicroPython

Here I found a perfect step-by-step tutorial on how to setup MicroPython on the Raspberry Pi Pico and use the lightweight Python IDE Thonny to run your first sketch.

Download the Display Driver for the Pico LCD

The driver software is directly available from the product site.

wget  https://www.waveshare.com/w/upload/2/28/Pico_code.7z

The driver is a simple MicroPython program that must be deployed onto the Pico as main.py which then takes control over the LCD.

Upon a closer look, we can see that the LCD_1inch8 class that acts as the driver for the hardware derives from the MicroPython FrameBuffer class. This means all its convenience methods like rect, ellipse, text, ... are available to us.

The Spooky Eve Code

Knowing that, we can do the whole (admittedly very plain) implementation of the spooky eye with just a few ellipse instructions. But don't judge me - I'm a bit late for this whole project, as it's Halloween today 😆.

#
# ... downloaded driver code
#
offs = 20
while True:
    x = 80 + offs
    y = 64
    
    LCD.fill(0)
    LCD.ellipse(x, y, 55, 55, LCD.RED, True)
    for r in range(25):
        LCD.ellipse(x, y, 30 + r, 30 + r, LCD.WHITE)
    LCD.ellipse(x, y, 30, 30, LCD.RED, True)
    LCD.ellipse(x, y, 15, 15, LCD.BLACK, True)
    LCD.show()
        
    offs = offs * -1
    time.sleep(2)

(find the complete source code here)

And we're done already!

Animated GIF of the spooky eye

Now I only need to attach the Pico to a portable battery and mount it somewhere outside our house to scare a few trick-or-treaters tonight.