Arduino firmware has two main tasks:

  • read pedaling cadence, transform it into click inter-times and sends clicks to the computer
  • receive the inclination and drive proportionally the brake

Since Arduino is a single task microcontroller it is necessary to share the execution time between the two tasks with an collaborative (non pre-emptive) scheduling in the main loop.

The project is based on the OOP model so each task is performed by a singletone object of a dedicated class.
Main application classes are:

  • SpeedReader: reads the pedaling cadence pulse, detects the trailing edge and computes speed storing it in term of pulses/second
  • UdpPeer:  receives the inclination as a string from the computer peer program and stores it as an integer.
  • BrakeActuator: converts  the stored inclination into a PWM output in order to drive the brake; the PWM output is enabled by the detection of movement in order to protect brake from overheat.
  • MouseEmulator: test the HID emulation enable switch and, if enabled, sends clicks to the computer
  • Control: links all above classes according with application logic rules

Besides application classes there are some utility classes:

  • Delay: not-suspensive programmable timer
  • InputStatus: input port status abstraction; base classe for events
  • InputEvent: retriggerable and direction programmable (trailing/falling)input trasition detector; based on InputStatus
  • DoubleInputEvent: retriggerable input transition detector (both edges); based on InputStatus
  • OutputStatus: virtual (abstract) class used as basis for specialized output classes
  • DigitalOutput: digital output port abstraction; based on OutputStatus
  • PwmOutput: analog output port abstraction; based on OutputStatus



A bike fit on a home trainer and equipped with a display showing a Street View which proceeds according to the pedalling pace. While riding, the incline is calculated and the brake torque is activated to simulate the slope.
The microcontroller is based on Arduino hardware.

facebook twitter google+ youtube flickr

And the winner is ...
Focus award

Meet Belluzzi Gooble Bike
at Maker Faire Rome
Maker Faire Europe Rome