David's dead reckoning code for the LVBots competition on March 6th. Uses the mbed LPC1768, DRV8835, QTR-3RC, and two DC motors with encoders.

Dependencies:   PololuEncoder Pacer mbed GeneralDebouncer

Revision:
32:83a13b06093c
Parent:
9:9734347b5756
--- a/motors.cpp	Tue Mar 04 03:04:00 2014 +0000
+++ b/motors.cpp	Tue Mar 04 04:32:51 2014 +0000
@@ -15,6 +15,9 @@
 DigitalOut motorLeftDir(p25);
 DigitalOut motorRightDir(p23);
 
+int16_t motorLeftSpeed = 0;;
+int16_t motorRightSpeed = 0;
+
 void motorsInit()
 {
     //PwmOut(p26).period_us(100);
@@ -45,8 +48,11 @@
     LPC_PWM1->TCR = (1 << 0) | (1 << 3);   // Enable the PWM counter and enable PWM.
 }
 
-void motorsSpeedSet(int16_t motorLeftSpeed, int16_t motorRightSpeed)
+void motorsSpeedSet(int16_t newMotorLeftSpeed, int16_t newMotorRightSpeed)
 {
+    motorLeftSpeed = newMotorLeftSpeed;
+    motorRightSpeed = newMotorRightSpeed;
+    
     if (motorLeftSpeed < 0)
     {
         motorLeftSpeed = -motorLeftSpeed;