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

Dependencies:   SevenSegmentDisplay mbed

Fork of mbed_blinky by Jon Fuge

Files at this revision

API Documentation at this revision

Comitter:
jf1452
Date:
Mon Feb 10 08:35:52 2014 +0000
Parent:
1:ff60bc1461ed
Commit message:
RenBED Counter Seven Segment Display

Changed in this revision

SevenSegmentDisplay.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SevenSegmentDisplay.lib	Mon Feb 10 08:35:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/jf1452/code/SevenSegmentDisplay/#cb7339a2e196
--- 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