-

Dependents:   STM32F407_Semafor

Files at this revision

API Documentation at this revision

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
--- /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
--- /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