-
Revision 0:441580ecf6c2, committed 2020-11-26
- Comitter:
- divicic
- Date:
- Thu Nov 26 07:51:49 2020 +0000
- Commit message:
- -
Changed in this revision
TrafficLight1.cpp | Show annotated file Show diff for this revision Revisions of this file |
TrafficLight1.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 441580ecf6c2 TrafficLight1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TrafficLight1.cpp Thu Nov 26 07:51:49 2020 +0000 @@ -0,0 +1,20 @@ +#include "TrafficLight1.h" +#include "mbed.h" +TrafficLight1::TrafficLight1(PinName pin) : _pin(pin) +{ + _pin = 0; +} +void TrafficLight1::flash(int n) +{ + for(int i=0; i<n*2; i++) { + _pin = !_pin; + } +} +void TrafficLight1::On () +{ + _pin = 1; +} +void TrafficLight1::Off () +{ + _pin = 0; +} \ No newline at end of file
diff -r 000000000000 -r 441580ecf6c2 TrafficLight1.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TrafficLight1.h Thu Nov 26 07:51:49 2020 +0000 @@ -0,0 +1,15 @@ +#ifndef MBED_TrafficLight1_H +#define MBED_TrafficLight1_H +#include "mbed.h" + +class TrafficLight1 +{ +public: + TrafficLight1(PinName pin); + void flash(int n); + void On(); + void Off(); +private: + DigitalOut _pin; +}; +#endif \ No newline at end of file