The example program for RenBED to deomonstrate ticker and the Seven Segment Display Driver

Dependencies:   SevenSegmentDisplay mbed

Fork of mbed_blinky by Jon Fuge

Revision:
2:249f10554a91
Parent:
1:ff60bc1461ed
--- a/main.cpp	Mon Feb 10 08:26:45 2014 +0000
+++ b/main.cpp	Mon Feb 10 08:35:52 2014 +0000
@@ -1,8 +1,27 @@
+/*******************************************************************************
+* This program demonstrates how to drive the seven segment display             *
+*                                                                              *
+* Jon Fuge                                                                     *
+* V1.0 10/2/2014 First issue of code                                          *
+*******************************************************************************/
+
 #include "mbed.h"
+#include "SevenSegmentDisplay.h"
+
+// Options to instantiate SevenSegmentDisplay are...
+// FADE: causes the number changes to fade in smoothly
+// INSTANT: causes the an instant number change
+// + FLASH: causes the display to flash
+SevenSegmentDisplay segmentled( FADE );
 
 DigitalOut myled(P0_21);
 
+void Counter();
+Ticker timeout;             //Create an instance of class Ticker called timeout.
+
 int main() {
+    timeout.attach(&Counter, 1);
+
     while(1) {
         myled = 1;
         wait(0.2);
@@ -10,3 +29,13 @@
         wait(0.2);
     }
 }
+
+void Counter()
+{
+    static int Count = 0;
+
+    segmentled.DisplayInt(Count);
+    Count = Count + 1;
+    if (Count == 100)
+        Count = 0;
+}
\ No newline at end of file