T-Rex Game Auto Jumper
By Rob Zwetsloot. Posted
For those who have used Google Chrome (which is apparently most people: gs.statcounter.com), you may have seen the screen that pops up when your internet connection fails.
It’s of a pixelated T-Rex, and if you press the space bar, you can kill time before your internet connection is restored by playing a little cactus-jumping game. If your internet goes down for a really long time, then maybe you can automate playing it.
Maker Bas op ten Berg presented us his project, the full name of which is ‘Automatic Jumping in the T-Rex Game: Detecting Cacti with a Raspberry Pi Pico CircuitPython HID Controller’, that does just that.
Advertisement
Get started with Raspberry Pi – everything you need to know to start your journey!
“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.
Rob is amazing. He’s also the Features Editor of Raspberry Pi Official Magazine, a hobbyist maker, cosplayer, comic book writer, and extremely modest.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles
Get started with Raspberry Pi in Raspberry Pi Official Magazine 161
There’s loads going on in this issue: first of all, how about using a capacitive touch board and Raspberry Pi 5 to turn a quilt into an input device? Nicola King shows you how. If you’re more into sawing and drilling than needlework, Jo Hinchliffe has built an underwater rover out of plastic piping and […]
Read more →
Win one of three DreamHAT+ radars!
That’s right, an actual working radar for your Raspberry Pi. We reviewed it a few months ago and have since been amazed at some of the projects that have used it, like last month’s motion sensor from the movie Aliens. Sound good? Well we have a few to give away, and you can enter below. […]
Read more →
RP2350 Pico W5 review
It’s Raspberry Pi Pico 2, but with a lot more memory
Read more →