Simple training demonstration to show the use enumeration

Dependencies:   USBDevice mbed

Fork of ConstantsVariablesArrays by Jon Fuge

Committer:
jf1452
Date:
Tue Nov 26 09:52:16 2013 +0000
Revision:
4:c4e451a1890f
Parent:
3:0f80147842c2
Enumeration Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jf1452 1:d9da28105bef 1 /*******************************************************************************
jf1452 4:c4e451a1890f 2 * This program demonstrates the use of enumeration *
jf1452 1:d9da28105bef 3 * *
jf1452 1:d9da28105bef 4 * Jon Fuge *
jf1452 2:db81cad8cb64 5 * V1.0 25/11/2013 First issue of code *
jf1452 1:d9da28105bef 6 *******************************************************************************/
dan 0:7dec7e9ac085 7
jf1452 2:db81cad8cb64 8 #include "mbed.h"
jf1452 2:db81cad8cb64 9 #include "USBSerial.h"
jf1452 3:0f80147842c2 10
jf1452 4:c4e451a1890f 11 enum DaysOfTheWeek { SUN , MON, TUE, WED, THUR, FRI, SAT };
jf1452 4:c4e451a1890f 12 enum MonthsOfTheYear { JAN = 1, FEB, MAR, APR, MAY, JUN,\
jf1452 4:c4e451a1890f 13 JUL, AUG, SEP, OCT, NOV, DEC};
jf1452 4:c4e451a1890f 14
jf1452 3:0f80147842c2 15 USBSerial serial; // Virtual serial port over USB. Use Teraterm as the interface
dan 0:7dec7e9ac085 16
dan 0:7dec7e9ac085 17 int main() {
jf1452 2:db81cad8cb64 18 wait (10); // Wait 10 seconds to connect port
jf1452 3:0f80147842c2 19
jf1452 4:c4e451a1890f 20 serial.printf("Sunday is day %i, April is the %i month of the year\n\r", SUN, APR);
jf1452 3:0f80147842c2 21
jf1452 2:db81cad8cb64 22 for(;;) {} // Loop forever
jf1452 3:0f80147842c2 23 }