Create this program
Dependencies: mbed HCSR04 HMC6352 PID TextLCD
Revision 6:44c3bfbe2553, committed 2015-08-11
- Comitter:
- KoiShin_Sakana
- Date:
- Tue Aug 11 13:11:05 2015 +0000
- Parent:
- 5:e07e380ddb93
- Commit message:
- update dribbler.h
Changed in this revision
--- a/dribbler.h Sat Aug 08 12:39:18 2015 +0000 +++ b/dribbler.h Tue Aug 11 13:11:05 2015 +0000 @@ -1,8 +1,8 @@ /** - * @file : dribbler.h (0.1) + * @file : dribbler.h (1.0) * @brief : dribble the ball * @author : Shinnosuke KOIKE - * @date : 2015/08/07 + * @date : 2015/08/11 */ #ifndef DRIBBLER_H @@ -11,25 +11,26 @@ #include "mbed.h" #include "motor.h" -class Dribbler : public Motor { +class Dribbler { public: Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR_); void dribble(float power); private: DigitalIn dribblerIR; + Motor dribblerMotor; }; -Dribbler::Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR) : - normal(normalDirect), reverse(reverseDirect), dribblerIR(dribblerIR_) { - powerLevel = new PwmOut(pwm); +Dribbler::Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR_) : + dribblerIR(dribblerIR_), dribblerMotor(normalDirect, reverseDirect, pwm) { + dribblerMotor.setLimit(0.8); } void Dribbler::dribble(float power) { if (dribblerIR == 0) { - run(power); + dribblerMotor.run(power); } else { - brake(); + dribblerMotor.brake(); } } @@ -43,7 +44,6 @@ int main(void) { Dribbler dribbler(D4, D7, D9, D0); - dribbler.setLimit(0.8); while (1) { dribbler.dribble(0.2); }
--- a/kicker.h Sat Aug 08 12:39:18 2015 +0000 +++ b/kicker.h Tue Aug 11 13:11:05 2015 +0000 @@ -39,7 +39,7 @@ void Kicker::count(void) { timer.start(); float val = timer.read(); - if (val >= 3) { + if (val >= 2) { this->enableKick = 1; } }
--- a/motor.h Sat Aug 08 12:39:18 2015 +0000 +++ b/motor.h Tue Aug 11 13:11:05 2015 +0000 @@ -20,7 +20,7 @@ void run(float power); // input -1 ~ 1 void brake(void); -protected: +private: float limit; PwmOut* powerLevel; DigitalOut normal;