Create this program

Dependencies:   mbed HCSR04 HMC6352 PID TextLCD

Revision:
5:e07e380ddb93
Parent:
3:901d18b901b4
Child:
6:44c3bfbe2553
--- a/dribbler.h	Fri Aug 07 06:51:51 2015 +0000
+++ b/dribbler.h	Sat Aug 08 12:39:18 2015 +0000
@@ -9,9 +9,43 @@
 #define DRIBBLER_H
 
 #include "mbed.h"
+#include "motor.h"
 
-class Dribbler {
-    
+class Dribbler : public Motor {
+public:
+    Dribbler(PinName normalDirect, PinName reverseDirect, PinName pwm, PinName dribblerIR_);
+    void dribble(float power);
+
+private:
+    DigitalIn dribblerIR;
 };
 
-#endif
\ No newline at end of file
+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);
+    }
+}
+ */