shalab shalab / Mbed 2 deprecated Tutorial03_SimpleMotorControl

Dependencies:   VNH5019MC mbed

Revision:
0:8a42934ad23a
Child:
1:35b072614734
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 20 04:56:44 2014 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "VNH5019MC.h"
+
+DigitalOut led1(LED1);
+Serial pc(USBTX, USBRX);
+
+// Motor
+VNH5019MC motor(p19, p20, p21, p22);
+
+int main() {
+    pc.printf("\r\n\r\n\r\n");
+    pc.printf("Shalab - Tutorial03_SimpleMotorControl\r\n");  
+    
+    int duty = 0;
+    bool increment = true;
+    
+    while(1) { 
+        if ( duty >= 100 ) increment = false;
+        if ( duty <= -100) increment = true;
+        if (increment) duty++;
+        else duty--;
+        
+        motor.move(duty);
+        led1 = !led1;
+        wait(0.2);
+    }
+}
\ No newline at end of file