deepakkumar telgar
/
DC_Motor
DC_Motor_rotation using switch
Fork of HelloWorld by
Revision 2:1e23df59fc31, committed 2016-12-01
- Comitter:
- deepakdtelgar
- Date:
- Thu Dec 01 11:50:12 2016 +0000
- Parent:
- 1:03c191369089
- Commit message:
- DC_Motor_rotation using switch
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DC_Motor.cpp Thu Dec 01 11:50:12 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); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DC_Motor.h Thu Dec 01 11:50:12 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); +};
--- a/main.cpp Sun Jan 01 20:57:57 2012 +0000 +++ b/main.cpp Thu Dec 01 11:50:12 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(); } +