“Using a Raspberry Pi Pico, a light dependent resistor (LDR), a breadboard, some DuPont cables, and tape, I automated the famous Google T-Rex game,” Bas explains. “The LDR detects differences in analogue measurements whenever it senses cacti, which are always dark-coloured and appear on the same plane. The analogue-digital converter [ADC] port of the Pico measures each passing cactus ten times per second. After a 0.2-second delay, the Human Interface Device [HID] library simulates pressing the ‘up’ button on the keyboard, making the T-Rex jump at the right time.”
For Bas it was a fun way to show people he teaches and trains how the HID libraries work in code: “I’ve found that simulating single or multiple key presses with embedded processors stimulates the creativity and inventiveness of training participants,” he tells us.
See the light
Raspberry Pi Pico was the obvious choice for Bas. “[It’s] easy to obtain, very cost-effective, and supports MicroPython, CircuitPython, and Arduino C++,” Bas says. “It has a small form factor, can be easily soldered onto a prototyping board using castellated connections, or placed into a breadboard using headers. Personally, I like the Pimoroni Pico Explorer Base for prototyping, as it includes a breadboard, LCD screen, buttons, and breakout connectors. I especially appreciate the MicroPython and CircuitPython capabilities – they’re easy to explain to students, powerful, [and have a] wide range of libraries.”
The build itself is fairly simple – an LDR is placed in front of the screen, with tape acting as ‘blinders’ to stop other light interference. A pull-up resistor was used to stabilise the measurements too.
“The program displayed the measured [light] values in real time, making it easy to define and adjust the threshold values to trigger the T-Rex’s jump,” Bas further explains. “I stored the delay time for simulating the ‘up’ button press in a Python variable, allowing for easy adjustments through Thonny.”
Jumping ahead
What’s next for the T-Rex Jumper? “I have various future plans for these types of educational setups,” Bas says. “I’m always excited when participants in my trainings come up with creative ideas for using HID functions in combination with sensors and actuators, as it means I’ve succeeded in educating them about computer science and improving their digital literacy. Personally, I find it very rewarding to develop and create accessibility tools for people with disabilities, as they can greatly improve quality of life and make a meaningful difference.
Speaking of the creative ideas they came up, here’s just a few: automatic typing poem generators, pedal-based keyboards, automated testing tools for user interfaces, automatic swiping of dating apps… the list goes on.