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.
Fork of MicroBitDALImageRewrite by
Diff: MicroBitLED.cpp
- Revision:
- 0:47d8ba08580f
diff -r 000000000000 -r 47d8ba08580f MicroBitLED.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MicroBitLED.cpp	Sun Apr 12 17:38:56 2015 +0000
@@ -0,0 +1,35 @@
+
+#include "inc/MicroBitLED.h"
+
+       
+/**
+  * Constructor. 
+  * Create an LED representation with the given ID.
+  * @param id the ID of the new LED object.
+  */
+MicroBitLED::MicroBitLED(int id, PinName name) :
+pin(name)
+
+{   
+    this->id = id;
+}
+
+
+ /**
+  * Sets this LED to the brightness specified.
+  * @param b The brightness to set the LED, in the range 0..255.
+  */    
+void MicroBitLED::setBrightness(int b)
+{
+    pin.write(b > 0);
+}
+
+ /**
+  * Tests the brightness of this LED.
+  * @return the brightness of this LED, in the range 0..255.
+  */    
+int MicroBitLED::getBrightness()
+{
+    return pin.read() == 0 ? 0 : 255;
+}    
+
    