
Interrupt experiment
Diff: main.cpp
- Revision:
- 1:1407e3388ad8
- Parent:
- 0:a8022529c815
- Child:
- 2:0713f69f55eb
--- a/main.cpp Sat Apr 13 13:21:20 2019 +0000 +++ b/main.cpp Sat Apr 13 14:12:42 2019 +0000 @@ -1,21 +1,31 @@ #include "mbed.h" +#include "C12832.h" -Serial pc(USBTX, USBRX); -PwmOut led(LED1); +C12832 lcd(p5, p7, p6, p8, p11); +InterruptIn button(p15); +DigitalOut led(LED1); +DigitalOut flash(LED4); -float brightness = 0.0; +int a = 0; -int main() { - pc.printf("Press '^' to turn LED1 brightness up, 'v' to turn it down\n"); - while(1) { - char c = pc.getc(); - if((c == '^') && (brightness < 0.5)) { - brightness += 0.01; - led = brightness; - } - if((c == 'v') && (brightness > 0.0)) { - brightness -= 0.01; - led = brightness; - } - } - } \ No newline at end of file +void flip() { + led = !led; + a = 1; + } + +int main () { + //button.mode(PullUp); + button.rise(&flip); + while (1) { + flash = !flash; + wait(0.25); + if (a == 1) { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Varable is ON\n"); + wait(2); + a = 0; + lcd.cls(); + } + } +} \ No newline at end of file