How to turn a bicycle into a joystick

Samir Ouahan
carpediem-tech
Published in
4 min readJun 27, 2023
Pong Game

Introduction

Hello everyone,

Today, I want to take you on an exciting journey of challenges, innovation, and problem-solving that I recently embarked on. In this journey, the main characters are a television, two bicycles, a series of cables and sensors, and a challenge posed by a well-known bicycle brand. The goal? To create an interactive game where two people, by riding bicycles, could play the classic game of Pong directly on a television screen.

Part 1: The Directionality of the Handlebar

Our adventure began with a fascinating challenge: how to give directionality to the bicycle handlebar so that it could guide the Pong bar on the television screen? The initial solution was a sensor known as a rotary encoder. These sensors, commonly used in industrial applications to monitor the rotation of mechanical objects, seemed like the perfect choice. We fixed the rotary encoder on the front of the handlebar with an L-bracket, creating a rotating steering system with a gear and a toothed belt. Thus, every time the handlebar was rotated, the sensor emitted signals that could be interpreted as movements of the game bar on the screen.

Rotary encoder

However, this system presented some mechanical challenges. There was not enough tension between the handlebar and the encoder, which meant that the toothed belt often skipped teeth, causing errors in the input data. We also noticed that the external exposure of the sensors made them vulnerable to possible damage during intensive use.

The definitive solution presented itself in the form of a three-axis sensor: the “Busirde GY-271 HMC5883L Triple Axis Compass Magnetometer Sensor Module for Arduino”. This three-axis magnetic compass accurately detects the direction of the handlebar. Once mounted on the rotating part of the handlebar, the sensor provided a constant and accurate flow of data, allowing for smooth and responsive game control.

Busirde GY-271 HMC5883L Triple Axis Compass Magnetometer Sensor

The Raspberry Pi, connected to the sensors, processed the received data and translated the handlebar movements into the game actions on the television screen. The movement to the right or left of the handlebar corresponded to the action of the Pong bar, creating an interactive and engaging gaming experience.The Raspberry Pi, connected to the sensors, processed the received data and translated the handlebar movements into the game actions on the television screen. The movement to the right or left of the handlebar corresponded to the action of the Pong bar, creating an interactive and engaging gaming experience.

Part 2: The Pedaling and the Speed of the Ball

The pedaling of the bicycle was another essential element to incorporate into our game. We wanted the speed of pedaling to influence the speed of the ball in the game, adding a further level of interactivity.

The first sensor we tried was an infrared proximity sensor “Flying Fish”. These sensors detect objects without the need for physical contact and seemed ideal for detecting pedal movement. We installed the sensor at the bottom of the bike, watching the pedal. Despite various calibration attempts and the addition of white tape on the pedal to improve light reflection, we noticed that the sensor was influenced by ambient light, compromising its functionality.

Infrared proximity sensor

The definitive solution was an ultrasonic distance sensor “HC SR04”. These sensors measure distance using ultrasonic waves and are not influenced by ambient light, making them ideal for our purpose. After various tests, we found that the ultrasonic sensor worked perfectly, ensuring precise and reliable control of the ball’s speed depending on the pedaling speed.

Ultrasonic distance sensor HC SR04

The Raspberry Pi, receiving data from the ultrasonic sensor, translated the pedaling speed into the ball’s speed in the game, displayed on the television screen. This added an additional level of challenge and interactivity to the game, making the experience even more engaging.

Conclusion

This project represented an exciting journey through innovation and creativity, transforming two simple bicycles into an exciting interactive game. Despite the challenges encountered, thanks to our tenacity and our ability to adapt and find new solutions, we were able to overcome these challenges and deliver a fun and innovative final product.

Today, I would like to take you on an exciting journey of challenges, innovation, and problem-solving that I recently embarked upon. In this journey, the protagonists are a television, two bicycles, a series of cables and sensors, and a challenge posed by a renowned bicycle brand. The goal? To create an interactive game where two people, by getting on the bicycles, could play the classic game of Pong directly on a television screen.

--

--

Samir Ouahan
carpediem-tech

Blockchain fanatic , electronics and installations , frontend developer.