Jieun Lee
/
7-segment_3
7-segment_mission_3
Diff: main.cpp
- Revision:
- 0:abb2c73da9d1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Apr 21 08:01:40 2022 +0000 @@ -0,0 +1,65 @@ +#include "mbed.h" + +DigitalOut greenLed(LED1); +BusOut my7Seg(PA_8, PA_9, PA_10, PC_9, PC_8, PC_7, PC_6, PA_11); +//DigitalIn exButton(PC_11); + + +DigitalOut inLed(LED1); +DigitalOut exLed(PA_12); +DigitalIn inButton(PC_13); +DigitalIn exButton(PC_11); + +int main() { + + my7Seg = 0xFF; + greenLed = 1; + int myseg; + char temp7Seg; + int n = 0; + int buffer = 0; + int preStatus = 0; + float tempVal = 0; + + while(1) { + + if ( 1 == preStatus && 0 == exButton ) { + inLed = !inLed; +// buffer = 1; + n += 1; + if (n == 6){ + n = 0; + } + } + preStatus = exButton; + + switch(n) { + case 0: + temp7Seg = ~0x77; + break; + case 1: + temp7Seg = ~0x7C; + break; + case 2: + temp7Seg = ~0x39; + break; + case 3: + temp7Seg = ~0x5E; + break; + case 4: + temp7Seg = ~0x79; + break; + case 5: + temp7Seg = ~0x71; + break; + + } +// buffer = 0; + greenLed = !greenLed; + my7Seg = (temp7Seg & 0x7F) | ((greenLed & 0x01)<<7); + + wait(0.25); + + + } +}