Updated version of RenBuggy Servo that can accept instructions based on time or distance.

Dependencies:   PinDetect mbed

Fork of RenBuggyServo by Renishaw

Revision:
3:01bc89d7ae8e
Parent:
2:287a808baad7
Child:
5:c06b90175a54
--- a/Car.h	Mon Mar 10 11:53:45 2014 +0000
+++ b/Car.h	Thu Mar 13 07:31:10 2014 +0000
@@ -29,6 +29,7 @@
 #define CAR_H
 
 #include "mbed.h"
+#include "PinDetect.h"
 
 /**
 * RenBuggyServo Example:
@@ -60,7 +61,7 @@
     myCar.setSpeed(20000);
     myCar.setDirection(0);
     
-    myCar.forwards();
+    myCar.forwards();   
     wait(1);
     myCar.setDirection(45);
     wait(1);
@@ -87,17 +88,19 @@
     
     int m_speed;
     
+    int m_encoderCount;
+    
     int m_servoRange;       // Pulsewidth range to full left/right from centre (1.5ms)
     float m_servoDegrees;   // Angle to full right/left turn from centre (0).
     
     float m_wheelCircumference; // The circumference of the wheel with stripes.
     int m_countsPerRevolution;  // The number of stripes on the wheel.
-    //InterruptIn m_stripeInterrupt;
+    
+    PinDetect m_sensor; // For debouncing.
     
-    //float distanceToTimeConverter(float distance);
+    void updateEncoderCount();
     
-    public:
-    
+    public:    
     /** Constructs the car with PwmOut objects for servo and motor.
     * 
     * @param servoPin is the pin used for pwm output for driving the servo.
@@ -112,10 +115,11 @@
     * @param motorPin is the pin used for pwm output for driving the motor.
     * @param countsPerRevolution is the number of counts the encoder
     * makes in one full cycle of the wheel.
-    * @param wheelCircumference: The circumference of the wheel being
+    * @param wheelCircumference is the circumference of the wheel being
     * read by the encoder.
+    * @param sensorPin is the pin required for the encoder for debouncing.
     */
-    Car(PinName servoPin, PinName motorPin, int countsPerRevolution, float wheelCircumference);
+    Car(PinName servoPin, PinName motorPin, int countsPerRevolution, float wheelCircumference, PinName sensorPin);
     
     /**
     * Deconstructs the car.