I loved Todd Kurt's use of our Person Sensor to display an eyeball that follows people around the room, so I decided to try it for myself. This project guide adapts Todd's code to work with a Raspberry Pi Pico and a nice display from Adafruit.
LCD DisplayTo get started, solder on the header pins to the display, and them wire them to these pins on your Pico using the female/female jumper leads.
Pin 21 (GP16, SPI0RX) (Yellow) => MISO> / SO
Pin 22 (GP17, SPI0CSn) (Green) => TFTCS / TC
Pin 23 (GND) (Brown) => Gnd / G
Pin 24 (GP18, SPI0SCK) (Orange) => SCK< / CK
Pin 25 (GP19. SPI0TX) (Blue) => MOSI< / SI
Pin 26 (GP20) (Black) => RST / RT
Pin 27 (GP21) (White) => DC / DC
Pin 39 (VSYS) (Red) => Vin / V+
The colors are those used on the wiring diagram below. There are two different abbreviations for pins on the display, on the front and the back of the board, so I've included both in the descriptions.
Person Sensor
Wiring up the sensor requires 4 jumpers, to connect VDD, GND, SDA and SCL. We're using I2C port 0, which on the Pico is assigned to GPIO4 (SDA, pin 6) and GPIO5 (SCL, pin 7) in software. Power is supplied from 3V3(OUT) (pin 36), with ground attached to GND (pin 38). If you're using Qwiic connectors, the colors will be black for GND, red for 3.3V, blue for SDA, and yellow for SDC. It's the same setup as the introductory CircuitPython sample code.
Mounting
You'll need the display and sensor both facing in the same direction, with the I2C connector of the sensor at the top, and the display's pins at the bottom, so they're in the right orientation.
Setting up Circuit Python
You should read the official guide to setting up CircuitPython on a Pico for the latest information, but here is a summary:
- Download CircuitPython for your board from circuitpython.org. The Pico version is available at circuitpython.org/board/raspberry_pi_pico/. This project has been tested using the `8.0.0-beta.2` version.
- Hold down the
bootsel
button on the Pico and plug it into a USB port. - Drag the CircuitPython uf2 file onto the
RPI-RP2
drive that appears.
Once you've followed those steps, you should see a new CIRCUITPY
drive appear. You can now drag code.py
files onto that drive and the Pico should run them.
Install Libraries
We need the adafruit_imageload and adafruit_st7789 libraries to draw the eyeball, so the first step is to download a big bundle of all the CircuitPython libraries from circuitpython.org/libraries. You'll need to find the right bundle for your CircuitPython version.
Once you have that downloaded, unpack the bundle on your local machine. In the file viewer, go to the lib
folder within the unpacked bundle and copy the adafruit_imageload
directory and the adafruit_st7789.mpy
file into the lib
folder on the CIRCUITPYTHON
drive.
Install the Code
Now your eyeball is set up, you need the CircuitPython code to draw and control your eyeball. If you're familiar with git
, you can use the command line to clone the github.com/usefulsensors/person_sensor_eyeballrepository. If not, you can just download the code as a ZIP archive from this link and unpack it on your machine.
Next copy the code.py
, eye0_ball2.bmp
, and eye0_iris0.bmp
files from this folder to the CIRCUITPYTHON
drive. You should notice that the green LED on the Person Sensor lights up when it sees your face, and see an eyeball that moves as you move you face within view of the sensor.
Next Steps
There's probably enough SPI pins to run two eyeballs from the Pico, if you want a pair? Have a wonderfully spooooky Halloween!
Comments