
dc motor rotations are depending upon the pins given to mbed board
Fork of HelloWorld by
Revision 2:d2ddd762da24, committed 2016-11-29
- Comitter:
- KIRAN_PALTANKAR
- Date:
- Tue Nov 29 12:58:13 2016 +0000
- Parent:
- 1:03c191369089
- Commit message:
- dc motor rotations are depending upon the pins given to mbed board
Changed in this revision
diff -r 03c191369089 -r d2ddd762da24 DC.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DC.cpp Tue Nov 29 12:58:13 2016 +0000 @@ -0,0 +1,19 @@ +#include "Dcmotor.h" +#include "mbed.h" + +Dcmotor::Dcmotor(PinName1 pin1,PinName2 pin2) : pins(pin1,pin2) { + pins = 0; +} + +void Dcmotor::Dc() { + if(pinnm==0) + { + pins=1; + wait(0.2); + } + if(pinnm==1) + { + pins=2; + wait(0.2); + } +}
diff -r 03c191369089 -r d2ddd762da24 DC.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DC.h Tue Nov 29 12:58:13 2016 +0000 @@ -0,0 +1,14 @@ +#ifndef MBED_Dcmotor_H +#define MBED_Dcmotor_H + +#include "mbed.h" + +class Dcmotor { +public: + DigitalIn pinnm(pin); + Dcmotor(PinName1 pin1,PinName2 pin2); + void Dc(); + +private: + BusOut pins(pin1,pin2); +};
diff -r 03c191369089 -r d2ddd762da24 main.cpp --- a/main.cpp Sun Jan 01 20:57:57 2012 +0000 +++ b/main.cpp Tue Nov 29 12:58:13 2016 +0000 @@ -1,12 +1,10 @@ #include "mbed.h" - -DigitalOut myled(LED1); - +#include "Dcmotor.h" + +Dcmotor Rotation; + int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); - } + Rotation.Dc(); + Rotation.Dc(); } +
diff -r 03c191369089 -r d2ddd762da24 mbed.bld --- a/mbed.bld Sun Jan 01 20:57:57 2012 +0000 +++ b/mbed.bld Tue Nov 29 12:58:13 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e +http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb \ No newline at end of file