![](/media/cache/profiles/23d3743ad75e4470e7ff7129351a9541.jpg.50x50_q85.jpg)
Single direction, PWM control of a DC Motor
Dependencies: Motor mbed tsi_sensor
Revision 0:a19ecb0b5364, committed 2015-11-30
- Comitter:
- TheFella
- Date:
- Mon Nov 30 13:06:59 2015 +0000
- Commit message:
- Single direction, PWM control for a DC Motor
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Mon Nov 30 13:06:59 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Motor/#f265e441bcd9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 30 13:06:59 2015 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "tsi_sensor.h" + + +TSIAnalogSlider tsi(PTB16, PTB17, 25); // Touch pad slider tied to touch pad pins, named tsi +PwmOut mSpeed(PTB0); +DigitalOut DirCon1(PTC1); +Serial pc(USBTX, USBRX); // USB Serial Port + +float readValue; +float speed = 0; + +int main() +{ + mSpeed.period(0.001); + + while(1) + { + pc.printf("\033[2J"); // Clear Screen and Home cursor + pc.printf("\033[H"); + readValue = tsi.readPercentage(); + pc.printf("TSI = %0.2f\n\r", readValue); + if ( readValue == 0 ) + { + mSpeed = 0; + DirCon1 = 0; + wait(0.2); + } + DirCon1 = 0; + mSpeed = readValue; + wait(0.2); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 30 13:06:59 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsi_sensor.lib Mon Nov 30 13:06:59 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Kojto/code/tsi_sensor/#976904559b5c