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
main.cpp
- Committer:
- rantistic
- Date:
- 2015-02-25
- Revision:
- 1:252cc1fa8e32
- Parent:
- 0:a2be69659f88
File content as of revision 1:252cc1fa8e32:
#include "mbed.h" #include "USBSerial.h" #include "SevenSegmentDisplay.h" //Virtual serial port over USB USBSerial serial; int countdown; int startno = 6; int 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("%d\n\r", countdown); wait(1); } countdown = 0; segmentled.DisplayInt(countdown); serial.printf("%d\n\r", countdown); serial.printf("Hi User! Please enter a number between 2 and 99\n\r"); serial.scanf("%d", &userinputno); segmentled.DisplayInt(userinputno); serial.printf("The countdown will now start from %d ... \n\r", userinputno); wait(1); startno = userinputno; } }