Dean Fraj
/
DC_motor_2
Program for controlling speed and rotation of motor
Revision 0:669350f3c18d, committed 2017-12-18
- Comitter:
- dfraj
- Date:
- Mon Dec 18 14:00:18 2017 +0000
- Commit message:
- Program for controlling speed and direction of motor
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 669350f3c18d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 18 14:00:18 2017 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +PwmOut smjer1(p21); +PwmOut smjer2(p22); +PwmOut ledica1(LED1); +PwmOut ledica2(LED2); +AnalogIn pot(p20); + +int main(){ + smjer1.period(0.00004); + while(true){ + if(pot >= 0 && pot < 0.5){ + smjer1 = (-2 * pot) + 1; + ledica1 = (-2 * pot) + 1; + smjer2 = 0; + } else if(pot > 0.5 && pot <= 1){ + smjer1 = 0; + smjer2 = (pot - 0.5) * 2; + ledica2 = (pot - 0.5) * 2; + } else{ + smjer1 = 0; + smjer2 = 0; + } + } +} \ No newline at end of file
diff -r 000000000000 -r 669350f3c18d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 18 14:00:18 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file