Library to control the bike (just basic for now)
Diff: BikeControl.cpp
- Revision:
- 0:792a8f167ac0
- Child:
- 1:39f462024f10
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BikeControl.cpp Mon Jul 18 09:25:53 2016 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "BikeControl.h" + +BikeControl::BikeControl(){ + //PullUp on userButton input + userButton.mode(PullUp); + //PullUp on brake inputs + brakeFront.mode(PullUp); + brakeRear.mode(PullUp); + + //Call function on rise of interruptpin + generatorHallA.rise(&generatorHallAPulsed); + generatorHallB.rise(&generatorHallBPulsed); + generatorBrake.period_us(50); + generatorBrake.write(0.5f); + generatorHallACounter=0; + generatorHallARpm=0; + generatorHallBCounter=0; + generatorHallBRpm=0; + + //motor + motorRightCtrl.period_ms(100); + motorRightCtrl.write(0.0f); + motorRightHall.rise(&motorRightPulsed); + motorLeftCtrl.period_ms(100); + motorLeftCtrl.write(0.0f); + motorLeftHall.rise(&motorLeftPulsed); + + //Button inputs + buttonGreen.mode(PullUp); + buttonRed.mode(PullUp); + buttonDirectionRight.mode(PullUp); + buttonDirectionLeft.mode(PullUp); + + //SWITCH + switchOn.mode(PullUp); + switchWalk.mode(PullUp); + } \ No newline at end of file