A quick example of how to use a 7 Segment CA display with a 74HC164 Shift Register.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tomfleet
Date:
Fri Feb 22 13:57:49 2013 +0000
Commit message:
Version 1, Working as expected.

Changed in this revision

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/main.cpp	Fri Feb 22 13:57:49 2013 +0000
@@ -0,0 +1,31 @@
+// Name: ShiftReg_7seg
+// Description: An example of how to print characters to a common anode 7-segment display.
+
+#include "mbed.h"
+#define dpMask 0x80 //bitiwse OR with data to enable decimal point
+SPI shiftReg (p5, p6, p7);
+DigitalOut MR (p8);
+DigitalOut myled(LED1);
+char charTable[16] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x83, 0xF8, 0x80, 0x98, 0x88, 0x83, 0xC6, 0xA1, 0x86 ,0x8E};//0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
+
+void setup()
+    {
+        MR = 0;
+        wait(0.1);
+        MR = 1;
+        shiftReg.write(0x00);
+        wait(1);
+        shiftReg.write(0xFF);
+        wait(1);
+    }
+    
+int main() {
+    setup();
+    while(1) {
+    for (int i = 0; i < sizeof(charTable); i++)
+        {
+            shiftReg.write(charTable[i]);
+            wait(0.2);  
+        } 
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 22 13:57:49 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file