Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HelloWorld by
Revision 2:2187486a8fea, committed 2016-11-25
- Comitter:
- goutami
- Date:
- Fri Nov 25 16:58:29 2016 +0000
- Parent:
- 1:03c191369089
- Commit message:
- DCmotor rotation based on switch pin
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DCmotor.cpp Fri Nov 25 16:58:29 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DCmotor.h Fri Nov 25 16:58:29 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
--- a/main.cpp Sun Jan 01 20:57:57 2012 +0000 +++ b/main.cpp Fri Nov 25 16:58:29 2016 +0000 @@ -1,12 +1,9 @@ #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(); +} \ No newline at end of file
--- a/mbed.bld Sun Jan 01 20:57:57 2012 +0000 +++ b/mbed.bld Fri Nov 25 16:58:29 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