![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Q2_3 indicating vevel of led
Diff: main.cpp
- Revision:
- 1:6757d2875f4f
- Parent:
- 0:d730f0a5befb
- Child:
- 2:2ff289a7fba1
--- a/main.cpp Mon Jul 20 20:12:59 2020 +0000 +++ b/main.cpp Mon Jul 27 14:49:14 2020 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "C12832.h" +Serial pc(USBTX, USBRX); // tx, rx InterruptIn joystickcenter(p14); InterruptIn wire(p9); DigitalOut led(LED1); @@ -9,7 +10,7 @@ void flip() { led = !led; // toggles the led when the joystick button is pressed. - i=1; + i=led; } int main() { @@ -17,15 +18,22 @@ wire.mode(PullUp); // With this, no external pullup resistor needed wire.rise(&flip); // attach the function address to the rising edge while(1) { // wait around, interrupts will interrupt this! + flash = !flash; // turns LED4 on if off, off if on wait(0.5); // the instruction to wait for half-second - + lcd.locate(0,0); + if(i==0) { + lcd.locate(0,0); + lcd.printf("stand-by \n\r"); + wait (0.1); + lcd.printf("LED1 = 0 \n\r"); + wait (0.2); + } if(i==1) { lcd.locate(0,0); - lcd.printf("button press detected"); - i=0; + lcd.printf("button press detected\n"); + lcd.printf("LED = 1 \n\r"); + wait (0.2); } - } -} - +} \ No newline at end of file