Includes a basic 4-bit binary counter function for the leds.

Dependents:   datalogging_RTC

Files at this revision

API Documentation at this revision

Comitter:
BaserK
Date:
Wed Jul 08 11:26:27 2015 +0000
Child:
1:dbabf5266268
Commit message:
First commit;

Changed in this revision

ledCounter.cpp Show annotated file Show diff for this revision Revisions of this file
ledCounter.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ledCounter.cpp	Wed Jul 08 11:26:27 2015 +0000
@@ -0,0 +1,16 @@
+#include "ledCounter.h"
+
+DigitalOut led1(LED1); // DigitalOuts are defined for the onboard LPC1768 leds 
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+// This function can display value(mod 16) as binary on LPC1768
+// For example =  12 = (1010) led2 and led4 will be ON, led1 and led3 will be OFF.
+void ledCounter(int value)
+{
+    led1=value%2;
+    led2=(value>>1)%2;
+    led3=(value>>2)%2;
+    led4=(value>>3)%2;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ledCounter.h	Wed Jul 08 11:26:27 2015 +0000
@@ -0,0 +1,13 @@
+#ifndef LEDCOUNTER_H
+#define LEDCOUNTER_H
+
+#include "mbed.h"
+
+extern DigitalOut led1;     // allow led1 to be manipulated by other files
+extern DigitalOut led2;
+extern DigitalOut led3;
+extern DigitalOut led4;
+
+void ledCounter(int value);  // function prototype
+
+#endif
\ No newline at end of file