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

Files at this revision

API Documentation at this revision

Comitter:
rantistic
Date:
Wed Feb 25 10:21:59 2015 +0000
Parent:
0:a2be69659f88
Commit message:
updated version so works with new libraries

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a2be69659f88 -r 252cc1fa8e32 main.cpp
--- a/main.cpp	Fri Oct 24 10:04:23 2014 +0000
+++ b/main.cpp	Wed Feb 25 10:21:59 2015 +0000
@@ -5,9 +5,9 @@
 //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
+int countdown;
+int startno = 6;
+int userinputno; // do not initialise scanf values as this creates problems
 
 SevenSegmentDisplay segmentled( FADE );
 Ticker timeout;
@@ -24,19 +24,19 @@
        for(countdown=startno; countdown>0; countdown--)
          {
              segmentled.DisplayInt(countdown);
-             serial.printf("%u\n\r", countdown);
+             serial.printf("%d\n\r", countdown);
              wait(1);
          }
         
         countdown = 0;        
         segmentled.DisplayInt(countdown);
-        serial.printf("%u\n\r", countdown);
+        serial.printf("%d\n\r", countdown);
         serial.printf("Hi User! Please enter a number between 2 and 99\n\r");
-        serial.scanf("%u", &userinputno);
+        serial.scanf("%d", &userinputno);
         segmentled.DisplayInt(userinputno);
-        serial.printf("The countdown will now start from %u ... \n\r", userinputno);
+        serial.printf("The countdown will now start from %d ... \n\r", userinputno);
            
-        wait(3);
+        wait(1);
         
         startno = userinputno;
     }