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.
main.cpp
- Committer:
- alanffrench
- Date:
- 2020-07-29
- Revision:
- 0:08877fa55d02
File content as of revision 0:08877fa55d02:
#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); } }