well 4 days of Youtube tutorials and a heap of online reading brought me to the realization that line coding sucks
. Got the basics and can now get my servo to do some simple commands however still a long way off being able to write code that makes the PWM output do what I really want it to do.
Enter Visuino. https://www.visuino.com/
For those not familiar with the product, it is a block programing package that allows you to assemble and link your logic then it writes the code for you and uploads it to your Arduino controller. Still a decent learning curve to get your head around all the logic options and how to put it together but for me at least, it has allowed me to assemble the logic and getting the PWM signal to react the way I wanted in a relatively short period.
Changed my mind on how to setup the button control. Now utilizing 3 buttons.
Operation is as follows:
press button 1 => fast ramp to 50% throttle and latch
press button 2 => fast ramp to 100% throttle and latch
You can toggle between the 2 buttons any time and latch each speed as required.
Press button 3 (microswitch on the brake lever) throttle is killed. However there is a 4 second ramp back to zero % so the motor deactivates smoothly.
So that it. the code is completed and i can now control my Vesc through the Vesc's PWM port. The ADC port on the Vesc is now freed up for the Metr Bluetooth interface which i should have in about a week. Happy days