DCmotor Rotation using select pin
Revision 0:2f9903b5df61, committed 2016-11-25
- Comitter:
- 2bv14ei014
- Date:
- Fri Nov 25 16:04:42 2016 +0000
- Commit message:
- DCmotor Rotation using select pin
Changed in this revision
diff -r 000000000000 -r 2f9903b5df61 HelloWorld.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HelloWorld.lib Fri Nov 25 16:04:42 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/HelloWorld/#03c191369089
diff -r 000000000000 -r 2f9903b5df61 dc_motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dc_motor.cpp Fri Nov 25 16:04:42 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); + } +} \ No newline at end of file
diff -r 000000000000 -r 2f9903b5df61 dc_motor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dc_motor.h Fri Nov 25 16:04:42 2016 +0000 @@ -0,0 +1,15 @@ +#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); +}; + \ No newline at end of file
diff -r 000000000000 -r 2f9903b5df61 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Nov 25 16:04:42 2016 +0000 @@ -0,0 +1,9 @@ +#include "mbed.h" +#include "Dcmotor.h" + +Dcmotor Rotation; + +int main() { + Rotation.Dc(); + Rotation.Dc(); +} \ No newline at end of file