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.
Revision 1:33f1afec7e23, committed 2020-08-16
- Comitter:
- rudolf5020
- Date:
- Sun Aug 16 14:54:21 2020 +0000
- Parent:
- 0:8a4ca94d9fc7
- Commit message:
- r1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jul 18 11:33:54 2020 +0000 +++ b/main.cpp Sun Aug 16 14:54:21 2020 +0000 @@ -1,30 +1,36 @@ #include "mbed.h" #include "C12832.h" - + C12832 lcd(p5, p7, p6, p8, p11); InterruptIn joystickcenter(p14); InterruptIn button(p9); DigitalOut led(LED1); DigitalOut flash(LED4); int i; // variable for flip function. +Timer debounce;// debounce P14 -void flip(){ +void flip() +{ + if (debounce.read_ms()>200)// if bigger than 1000 want flip led = !led; - i = 1; // toggles the led, when pressing a button connects to p5. - } - -int main() { + i = 1; + debounce.reset(); +} + +int main() +{ lcd.cls(); lcd.locate(0,0); - button.mode(PullUp); + joystickcenter.rise(&flip); + debounce.start(); + button.mode(PullUp); button.rise(&flip); while(1) { flash = !flash; - if( i == 1){ - lcd.printf("Button pressed"); - i = 0; - } - + if( i == 1) { + lcd.printf("Button pressed"); + i = 0; wait(0.25); } -} \ No newline at end of file + } +}