
Project Template for Headstart Course 2017
Dependencies: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
Diff: ModeA/ModeA.cpp
- Revision:
- 2:0f91b789d90a
- Parent:
- 0:d5312060f649
- Child:
- 4:4269457cf8d8
--- a/ModeA/ModeA.cpp Mon Mar 13 07:01:51 2017 +0000 +++ b/ModeA/ModeA.cpp Mon Jul 10 10:07:01 2017 +0000 @@ -5,13 +5,40 @@ lcd.clear(); lcd.printString("Mode A",0,0); lcd.refresh(); - wait_ms(250); // small delay to prevent previous press being detected again + wait_ms(250); + + int segments[10] = {}; // Enter your hex values here! + int count = 0; + + update_display(count, segments[count]); while (button_a.read() == 0) { - // code goes in here - this acts like the main while(1) loop + if(button_b.read() == 1){ + count++; + update_display(count, segments[count]); + wait_ms(250); + } + if(button_d.read() == 1){ + count--; + update_display(count, segments[count]); + wait_ms(250); + } + + sevenSeg.write(segments[count]); } +} + +void update_display(int count, int hex){ + char count_string[14]; + sprintf(count_string, "Count = %d ", count); + lcd.printString(count_string,0,2); + char hex_string[14]; + sprintf(hex_string, "Hex: %#04x ", hex); + lcd.printString(hex_string,0,3); + lcd.refresh(); + } \ No newline at end of file