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