Shichong Zhang / Mbed 2 deprecated Szhang

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Toary
Date:
Thu Oct 22 10:46:46 2015 +0000
Commit message:
created my library

Changed in this revision

Led/Led.cpp Show annotated file Show diff for this revision Revisions of this file
Led/Led.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led/Led.cpp	Thu Oct 22 10:46:46 2015 +0000
@@ -0,0 +1,20 @@
+#include "Led.h"
+
+Led::Led(string s)
+{
+    if(s == "red")
+       pin = PD_14;
+       
+    l = new DigitalOut(pin);
+    
+}
+
+void Led::On()
+{
+    l->write(1);
+}
+
+void Led::Off()
+{
+    l->write(0);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led/Led.h	Thu Oct 22 10:46:46 2015 +0000
@@ -0,0 +1,19 @@
+#ifndef LED_H
+#define LED_h
+
+#include "mbed.h"
+#include <string>
+
+class Led 
+{
+    private:
+    PinName pin;
+    DigitalOut *l;
+    
+    public:
+        Led(string s);
+        void On();
+        void Off();
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 22 10:46:46 2015 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+#include "Led.h"
+
+Led red("red");
+
+int main()
+{
+    while(1)
+    {
+        red.On();
+        wait(0.5);
+        red.Off();
+        wait(0.5);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 22 10:46:46 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file