Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:08877fa55d02
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 29 18:48:17 2020 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "C12832.h" + + +InterruptIn joystickcenter(p14); +InterruptIn button(p9); +DigitalOut led(LED1); +DigitalOut flash(LED4); +C12832 lcd(p5, p7, p6, p8, p11); +Timer debounce; +int i = 0; + +void flip() +{ + if( debounce.read_ms() > 100) // will accept next push button at least 100ms from last press, avoiding bouncing switch effect + { + led=!led; + i = 1; + debounce.reset(); + } +} + + +int main() +{ + joystickcenter.rise(&flip); + button.mode(PullUp); + button.rise(&flip); + debounce.start(); + + while (1) { + flash = !flash; + if(i==1) { + lcd.printf("BANG! "); //keep printf outside interrupt - better as the interrupt needs to be as short as possible + i = 0; + } + wait(0.25); + } +}