Basic Led Library

Files at this revision

API Documentation at this revision

Comitter:
WakoTakeru
Date:
Sat Feb 18 04:11:45 2017 +0000
Commit message:
Basic Led Library

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 ccc1d1ad706f LED.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LED.cpp	Sat Feb 18 04:11:45 2017 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+#include "LED.h"
+
+Led::Led(PinName pin):_pin(pin){
+    _pin = 0;
+    state = false;
+}
+
+void Led::On(){
+    _pin = 1;
+    state = true;
+}
+void Led::Off(){
+    _pin = 0;
+    state = false;
+}
+
+void Led::Toggle(){
+    if(state){
+        Led::Off();
+    }else{
+        Led::On();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r ccc1d1ad706f LED.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LED.h	Sat Feb 18 04:11:45 2017 +0000
@@ -0,0 +1,14 @@
+#ifndef __LED_H__
+#define __LED_H__
+#include "mbed.h"
+class Led{
+private:
+    DigitalOut _pin;
+    bool state;
+public:
+    Led(PinName pin);
+    void On();
+    void Off();
+    void Toggle();
+};
+#endif
\ No newline at end of file