Parts List
Teensy 2.0 Microcontroller – US$19
Teensy 2.0 uses 5v logic, so is easier to use with a rotary encoder that requires 5-20v. (Other Teensy models work, other than the LC which doesn’t support 5v logic.)
Official Store – PJRC – US$19
Australian Stockist – Little Bird – AU$29
Rotary Encoder – $16
6mm shaft rotary encoder, ~360-400 Pulse/Rotation.
Amazon.com – US$16
Ebay Australia – AU$15
3D Printed Parts
Three parts are required: Encoder Gear, Crank Gear, and Encoder Bracket. All are available on Thingiverse.
Other Parts
- Exercise Bike (or other rotation-based exercise equipment)
- Game Controller (or Keyboard/Mouse)
- Long releasable cable ties/velcro ties/tape to attach bracket to equipment
- Long USB cable (optional)
- Long headphone cable (optional)
Software
PC: x360ce (free)
Mac: ControllerMate (US$25)
Teensy Code: Exercise-Bike-Controller on Github
Construction
- Print all 3 parts
- Attach printed Encoder Gear to the encoder shaft
- Remove bike casing and the pedal on the opposite side to the drive belt
- Screw printed pedal gear on to crank, and then put pedal back on
- Connect encoder to Teensy, either solder pins directly or using a breadboard:
Red Wire (Pulse): Pin D0 (pin 5 on Teensy 2.0 and in Arduino software)
Green Wire (Pulse): Pin D1 (pin 6 on Teensy 2.0 and in Arduino software)
White Wire (+5V): Pin VCC
Black Wire (Ground): Pin GND
(These wire colours may change depending on your encoder source – so check your part documentation, or do some testing before soldering to the board) - Use Encoder Bracket and cable ties to attach the encoder to bike frame, so the gears mesh together. Cable ties allowed me to adjust the encoder position to ensure the gears weren’t pressed together too hard
- Use some more cable ties/velcro to keep cables away from moving parts
- Plug Teensy into your computer with long USB cable
Configuring Software
- Teensy – First follow the official TeensyDuino tutorials to get set up and ensure Teensy 2.0 is working correctly
- Download the Exercise_Bike_Controller arduino sketch from Github and open in Arduino software
- Set the Arduino software to use Teensy as a Joystick under menu: Tools > USB Type > Serial + Keyboard + Mouse + Joystick
- Upload the sketch to Teensy (Ensure that “Teensy” is selected under menu: Tools > Port), open Serial Monitor and test that the encoder values are changing when the crank moves
- Test your maximum pedalling speed outputs a value of +512, increase or decrease the “speedMultiplier” variable (line 17) if you’d like to pedal faster or slower to output full speed on your controller
- Once you’re happy with your pedalling speed, change the “readDelay” variable (line 20) to 5, to make the controller latency faster
PC – x360ce
Connect Teensy and Xbox Controller (or other controller). Copy x360ce into game location (for Rocket League this is: /Program Files (x86)/Steam/steamapps/common/rocketleague/Binaries/Win32/)
When playing without exercise controller, you need to temporarily remove the xinput1_3.dll file, or the game won’t start correctly.
Configuration:
Combine this controller: Combine into: One
Mac – ControllerMate
ControllerMate script is available on Github. The “Bike Controller Axes” page should contain “Wireless 360 Controller” and “Teensy Keyboard/Mouse/Joystick.” If you’re using a different controller, you may need to add the axes yourself.
The “Bike Controller Combined” page should create a virtual controller.
Start your game, and enjoy the exercise!
Video Transcript
Hey there Internet. I’m Jaymis, and I have a project I’ve been working on, that I’d like to share with you.
6 replies on “Exercise Bike Controller”
Thanks for this.
Warning to anyone building this: I got a rotary encoder off amazon that ended up having different colors assigned to the pinout. The encoder didn’t come with any paperwork. But it did have mandarin on the side of the encoder. Got someone to translate it for me, and figured out the correct colors to hook up.
Hello, I’m trying to set-up this bike but I’m a very visual learner, is there any way we could get a video tutorial?
Sorry Alex, creating that kind of tutorial is very time-consuming.
Also, each exercise bike is quite different, so this page is designed as more an overall guide to creating a similar system. It would need to be customised to the mechanical layout of your gear.
[…] instructions, designs, code and links: http://jaymis.com/2016/06/exercise-bike-controller/ Reddit discussion/even more information: […]
Hi Jaymis. I have been obsessed with this idea for more than a decade. I have been so disappointed with all the retail options thus far. I got super excited about your website. My mechanical layout is nearing completion. I visited a tech minded buddy today and he said the instructions for the encoder are inadequate. He said if he puts the wires in the wrong place we will just blow up the Teensy Micro controller. My mechanical layout is quite different to yours. I would love to interact with you by email. I think you would be excited about my goals and creative differences in the mechanical layout.
Sir can you explain how the car in the game is moving when we pedal the cycle. Hoping for a reply since we are in stage of implementation of this project.