Create this program
Dependencies: mbed HCSR04 HMC6352 PID TextLCD
dribbler.h
- Committer:
- KoiShin_Sakana
- Date:
- 2015-08-08
- Revision:
- 5:e07e380ddb93
- Parent:
- 3:901d18b901b4
- Child:
- 6:44c3bfbe2553
File content as of revision 5:e07e380ddb93:
/** * @file : dribbler.h (0.1) * @brief : dribble the ball * @author : Shinnosuke KOIKE * @date : 2015/08/07 */ #ifndef DRIBBLER_H #define DRIBBLER_H #include "mbed.h" #include "motor.h" class Dribbler : public Motor { public: Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR_); void dribble(float power); private: DigitalIn dribblerIR; }; Dribbler::Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR) : normal(normalDirect), reverse(reverseDirect), dribblerIR(dribblerIR_) { powerLevel = new PwmOut(pwm); } void Dribbler::dribble(float power) { if (dribblerIR == 0) { run(power); } else { brake(); } } #endif /** * example program #include "mbed.h" #include "dribbler.h" int main(void) { Dribbler dribbler(D4, D7, D9, D0); dribbler.setLimit(0.8); while (1) { dribbler.dribble(0.2); } } */