Regen braking is much simpler to implement, as it just requires the right input to the right pin on the controller. If there was more space, I would have liked to use another pot to be able to vary the amount of regen braking: more or less depending on how far the pedal is depressed. However, given the lack of space we are just going to use Pin25 on the controller to activate/deactivate. This requires a 12V signal, which we can helpfully draw from the rear brake light, which is connected to what was the rear brake pedal. Now, when the pedal is depressed, the motor starts regen braking: delivering a small amount of power back into the motor. This has taken some testing to get the required amount of regen: too much and it's too sudden and overloads the BMS's charging capacity, too little and it doesn't slow the bike at all. There is a lingering issue that regen doesn't currently work at full charge: as the regen current is enough to trigger the BMS over-voltage protection, but that can be sorted out with software - I think...