Takes a user input (value between 0 and 99) and starts a countdown from that value. The countdown is printed to the serial port and to the 7 segment displays on the RenBed.

Dependencies:   SevenSegmentDisplay USBDevice mbed

Revision:
0:a2be69659f88
Child:
1:252cc1fa8e32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 24 10:04:23 2014 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "USBSerial.h"
+#include "SevenSegmentDisplay.h"
+ 
+//Virtual serial port over USB
+USBSerial serial;
+
+uint8_t countdown;
+uint8_t startno = 6;
+uint8_t userinputno; // do not initialise scanf values as this creates problems
+
+SevenSegmentDisplay segmentled( FADE );
+Ticker timeout;
+
+void attimeout();
+
+int main(void)
+{
+
+            
+    while(1)
+    {
+       wait(1);
+       for(countdown=startno; countdown>0; countdown--)
+         {
+             segmentled.DisplayInt(countdown);
+             serial.printf("%u\n\r", countdown);
+             wait(1);
+         }
+        
+        countdown = 0;        
+        segmentled.DisplayInt(countdown);
+        serial.printf("%u\n\r", countdown);
+        serial.printf("Hi User! Please enter a number between 2 and 99\n\r");
+        serial.scanf("%u", &userinputno);
+        segmentled.DisplayInt(userinputno);
+        serial.printf("The countdown will now start from %u ... \n\r", userinputno);
+           
+        wait(3);
+        
+        startno = userinputno;
+    }
+}