This is a software solution and will be less accurate in it's implementation than a hardware solution would be. But I'll leave hardware solutions to the Lecky-Techies ...
I had written about 25% of what I would expect to be the total code required when I received the PM's. This has led me to write some use cases before recommencing the code. Please feel free to add to / help solidify these. Here they are ...
/*==========================================================================================
Arduino Throttle Interface
============================================================================================
This describes the Use Cases for this "Sketch" [as Arduino refers to source code

]
The aims of this "sketch" are to provide a simple system that acts as a "Big Brother" monitoring and control system, whilst enabling the simplest of user controls.
It is most relative to those of us who use their bicycles as low powered commuters*, which probably excludes those who choose to use RC motors. In fact, this is only written to provide a throttle input into a XeiChang (AKA Infineon) type controller (one whose speed is controlled by varying the throttle input between 1.0V and 4.2V). There are two reasons for this:
1. I am using a hub motor and not a RC motor (at least not just yet anyway

)
2. adrian_sm's "Commuter Booster - <1 kg Friction Drive" has this implemented. I don't
intend on re-inventing the wheel (although 1. may influence this).
This does not mean that you can't modify it to control an ESC for RC motors - you can

[If you do, please either post it here or PM me if you wish it to remain private]
As this is open source, instead of providing a myriad of configuration switches, constants are used throughout the "sketch" to configure user parameters. Each one is documented in it's intended use and suitable values. Comment out those that do not apply to your circumstances.
* Upto 2kW is considered low powered in this context
============================================================================================
Push-button throttle
A push-button throttle provides several advantages over a normal throttle. These include:
1. The reduction in throttle variation while riding over undulating / corrugated surfaces,
which causes the rider's hand / thumb to vary the throttle. However, I don't think this
is a major consideration for lower powered commuters.
2. Eliminates the need for the rider to continuously operate the throttle
3. Eliminates breakages of normal throttles caused by [1] and [2]
4. It has the greatest reliability due to it's simplicity (less moving parts)
5. It is (probably) legal in countries where a normal throttle is not, as a push-button is ON/OFF.
============================================================================================
UC01
Pushing and holding the throttle button whilst pedalling, quickly ramps the output signal from 1.0V to 4.2V until the bike reaches the rider's preferred "cruising speed", where the rider releases the button. The bike then maintains that speed, including whilst climbing hills, until the rider stops pedalling.
UC02
Resumption of pedalling accelerates the bike up to the previous "cruising speed" without the rider having to push the throttle button. The bike must already be moving for the resumption to be immediate.
UC03-4
The previous "cruising speed" can be overridden during resumption by the rider pushing the throttle button, either momentarily to set a lower "cruising speed", or continuously to increase the previous "cruising speed".
UC05
To prevent accidental activation of the resume function, pushing the throttle button while depressing a nominated brake lever resets the "cruising speed" to 0. To disable accidental activation without resetting the speed to 0, the brake lever is depressed.
UC06
An alternative strategy to UC05 is to enable resume only after a minimum speed is obtained, and 7.5kmh is the suggested speed. Pressing the throttle button below this speed resets the "cruising speed" to 0.
============================================================================================
UC07 (Normal throttle)
The use of a "normal" throttle does provide an advantage over a push-button throttle in that the speed and rate of acceleration of the bicycle are under direct rider control.
However, unless you are performing one or more of UC08-UC13, using this throttle interface just adds complexity for zero gain.
============================================================================================
Monitoring and control
UC08 (Piezo buzzer)
A piezo buzzer (OT02) will emit sounds indicating several conditions, including error conditions. It is yet to be determined whether to indicate each individual error as a different sound, or just one sound for all error conditions.
UC09 (Battery Load)
Battery load will be monitored through a sensor. This enables other functions (UC10, UC11, UC13). It also allows us to provide a "fuel tank" gauge in the same manner as previously described by Jeremy Harris ie by calculating amp-unit seconds used and subtracting it from the total pack's amp-unit seconds. This value is stored in EEPROM.
The "sketch" includes all the code required for this other than the driving of the gauge itself.
** What sensors are available and where do I get one from in Australia? **
UC10 (Phase Load)
Phase load isn't measured by this "sketch" but calculated as a function of battery load and bike speed. Exceeding the phase load limit will reduce the throttle output.
** User input is invited to determine this function. **
UC11 (LVC)
The controller I am using with my 12S LiPo pack is set at 31.5V (2.625V per cell), which is well under the safe voltage for a LiPo cell. The controller could be modified to increase the LVC, but using software LVC provides greater flexibility (and much quicker to change).
There are three set points in the "sketch" that trigger actions based on the pack voltage (and therefore cell voltage).
The LVC-H (nominally 3.7V = analog757) reduces the throttle output until such time as the voltage rises above the set point.
The LVC-M (nominally 3.6V = analog736) reduces the throttle output until the battery load falls to 7A.
The LVC-L (nominally 3.5V = analog716) provides 0 throttle output.
============================================================================================
UC12 (Power on mode)
On power up, two push buttons may be pressed to:
1. Reset the battery capacity to "full"
2. Bypass the Oz Legal Mode for off-road use only
Upon successful start up, the piezo buzzer will sound indicating OZ Legal mode (UC13), or off-road mode (which also indicates legal mode in other parts of the world)
============================================================================================
UC13 (Oz legal mode)
To be legal in Australia, the assistance provided by the motor to the bicycle must be controlled by pedalling, be limited to a top, assisted speed of 26kmh, and to provide no more than 200W assistance.
To implement "controlled by pedalling", the act of pedalling is defined here as having rotation of the cranks of at least 10rpm.
To limit the motor power to 200W requires the battery load be limited to 7A.
===========================================================================================
IO
Digital Inputs:
DI01 - Pedal sensor: This is usually implemented by having a hall effect sensor mounted on the bottom bracket with a rotating disk mounted to the crank shaft. The hall sensor picks up the magnets' field as each magnet passes the sensor, providing a pulse. This pulse will be input to one of the Interrupts (0) to ensure the pulse is caught by the sketch. Note that Interrupt(0) is actually digital pin (2).
DI02 - Speed sensor: This is usually implemented by having magnets mounted on the spokes of the wheel, and having a hall sensor mounted in close proximity to the path the magnets take whilst the wheel is rotating. The hall sensor picks up the magnets' field as each magnet passes the sensor, providing a pulse. This pulse will be input to one of the Interrupts (1) to ensure the pulse is caught by the sketch. Note that Interrupt(1) is actually digital pin (3).
DI03 - Push-button throttle: Any spring return, momentary contact switch will suffice. Naturally, one that is designed (or easily modified) to suit bicycle handlebars is preferred. State signal connected to digital pin (4)
DI04 - Brake lever: State signal connected to digital pin (5).
Digital Inputs Power On:
DI05 - Battery Capacity Reset: Any small, momentary contact switch will suffice. State signal connected to digital pin (11).
DI06 - Oz Legal Mode Overide: Any small, momentary contact switch will suffice. State signal connected to digital pin (12).
Analog Inputs:
AI01 - Normal throttle input will be to analog input (0).
AI02 - Battery load sensor will be connected to analog input (1)
AI03 - Pack voltage will be supplied through a voltage divider connected to analog input (2)
Outputs:
OT01 - Signal input to the controller. This will be implemented on PWM digital pin (9).
OT02 – A piezo buzzer. This will be implemented on PWM digital pin (10).
===========================================================================================
*/