SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Revision:
4:25e028102625
Child:
8:92f6baeea027
diff -r c8867972ffc7 -r 25e028102625 Motor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp	Thu Feb 02 23:30:41 2017 +0000
@@ -0,0 +1,72 @@
+#include "Motor.h"
+#include "mbed.h"
+/*
+DigitalOut DIR_L(PTA13);
+DigitalOut DIR_R(PTC9);
+
+PwmOut PWM_L(PTD0);
+PwmOut PWM_R(PTD5);
+
+Motor::Motor()
+{
+    
+}
+    
+void Motor::initializeMotor()
+{    
+}
+
+void Motor::setLeftSpeed(int speed)
+{
+    init();
+    PWM_L.period_us(60);
+    
+    bool reverse = 0;
+    
+    if(speed < 0)
+    {
+        speed = -speed;
+        reverse = 1;    
+    }
+    //Set Max Speed
+    if(speed > 60)
+        speed = 60;
+        
+    if(reverse)
+        DIR_L = 1;
+    else
+        DIR_L = 0;
+
+    PWM_L.pulsewidth_us(speed);
+}
+
+void Motor::setRightSpeed(int speed)
+{
+    init();
+    PWM_R.period_us(60);
+    
+    bool reverse = 0;
+    
+    if(speed < 0)
+    {
+        speed = -speed;
+        reverse = 1;    
+    }
+    //Set Max Speed
+    if(speed > 60)
+        speed = 60;
+        
+    if(reverse)
+        DIR_R = 1;
+    else
+        DIR_R = 0;
+    
+    PWM_R.pulsewidth_us(speed);
+}    
+
+void Motor::setSpeeds(int leftSpeed, int rightSpeed)
+{
+    setLeftSpeed(leftSpeed);
+    setRightSpeed(rightSpeed);    
+}
+*/
\ No newline at end of file