Simple PWM for motor control

Dependencies:   mbed

This program is for motor control with Arduino motor shield and LCP 1768.

For motor control with arduino motor shield, it needs direction signal and brake signal. Maybe brake signal is optional. So, the code use three pins, direction(gpio), brake(gpio) and PWM output.

- Schematic /media/uploads/hjjeon/lpc1768_motor_shield_schem.jpg

Revision:
1:4f47e58cd882
Parent:
0:5f85a7752a04
Child:
2:4eb08f46fc91
--- a/main.cpp	Tue Nov 18 02:16:00 2014 +0000
+++ b/main.cpp	Tue Nov 18 02:20:03 2014 +0000
@@ -10,15 +10,15 @@
     Serial pc(USBTX, USBRX);
     pc.baud(115200);
     
-    PwmOut mypwm(p21);
-    DigitalOut direction(p5);
-    DigitalOut brake(p6);
+    PwmOut mypwm(p21);// NXP 1768 platform PWM output
+    DigitalOut direction(p5);// NXP 1768 platform GPIO pin #5 output
+    DigitalOut brake(p6);// NXP 1768 platform GPIO pin #6 output
     
     direction = FORWARD;// FORWARD == 0;.
     
     while(1) {
         myled = !myled;
-        mypwm = mypwm + 0.05;
+        mypwm = mypwm + 0.05;// 0.05 is 5% duty pulse width
         wait(3);
         if( mypwm >= 1)
         {