Portfolio About CV LinkedIn Instagram

Self-Balancing Segway


This was undertaken as a solo challenge for my second electronics module. We were given the parts to assemble the segway, and then set the challenge to write the code to control it, such that it self-balanced and danced in time to music.


The videos below show my finished attempts at the challenges. The self-balancing highlights my understanding of proportional-integral-derivative (PID) control - using the pitch angle as the set-point variable to control the motors such that the pitch angle is maintained at zero (segway is upright).
The dancing then adds another challenge in the form of beat detection. This algorithm is implemented using a sample buffer that relies on a timer interrupt to periodically sample the music. Another buffer then stores the instantaneous energies of the past 50 epochs (20 ms time periods), and if the ratio of the current instantaneous energy to the sum of the past 50 epochs is above a certain threshold, this counts as a beat detected and the next dance move is queued.

Short video showing the stability of my self-balancing segway

Short video of the segway dancing to the beat of the music

_________ Skills Developed _________

Soft Skills

Problem Solving

Hard Skills

Electronics (Signal Interpretation & Feedback Systems) | Coding (MicroPython)