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.
Revision 0:5b4ae278e1b8, committed 2017-09-30
- Comitter:
- nguyenmanhthao996tn
- Date:
- Sat Sep 30 09:12:38 2017 +0000
- Commit message:
- Worked version
Changed in this revision
Led.cpp | Show annotated file Show diff for this revision Revisions of this file |
Led.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 5b4ae278e1b8 Led.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led.cpp Sat Sep 30 09:12:38 2017 +0000 @@ -0,0 +1,21 @@ +#include "Led.h" + +Led::Led(PinName pin) +{ + this->myled = new DigitalOut(pin); +} + +void Led::Toggle(void) +{ + *(this->myled) = !this->myled->read(); +} + +Led_State Led::ReadState(void) +{ + return (Led_State)(this->myled->read()); +} + +void Led::WriteState(Led_State state) +{ + *(this->myled) = (int) state; +}
diff -r 000000000000 -r 5b4ae278e1b8 Led.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led.h Sat Sep 30 09:12:38 2017 +0000 @@ -0,0 +1,26 @@ +#ifndef __LED__ +#define __LED__ + +/*********** Libraries ***********/ +#include "mbed.h" +#include "PinConfiguration.h" + +/*********** Data Types ***********/ +typedef enum Led_State_Enum { + Led_State_Off = 0, + Led_State_On +} Led_State; + +class Led +{ +private: + DigitalOut* myled; +public: + Led(PinName pin); + + void Toggle(void); + Led_State ReadState(void); + void WriteState(Led_State state); +}; + +#endif /* __LED__ */ \ No newline at end of file