
Assignment 5 for OCE360, timers, tickers, and interrupts.
Dependencies: 4DGL-uLCD-SE MMA8452Q SDFileSystem bouncing_ball mbed
Fork of OCE360_4 by
Revision 7:614b40b85579, committed 2017-11-09
- Comitter:
- rsean10
- Date:
- Thu Nov 09 16:01:24 2017 +0000
- Parent:
- 6:050104c0dc75
- Child:
- 8:2617100c441d
- Commit message:
- Interrupt added, non-functioning, attempting comment blocking to find error
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 09 15:14:23 2017 +0000 +++ b/main.cpp Thu Nov 09 16:01:24 2017 +0000 @@ -27,9 +27,18 @@ //Led Initialization DigitalOut led1(LED1); //update leds DigitalOut led2(LED2); +DigitalOut led3(LED3); -//Button Initialization -DigitalIn button(p13); +//Toggle Initialization +InterruptIn button(p13); //Interrupt on the button on pin 13 +Timer debounce; //defines debounce timer for proper switching + +void toggle(){ + if(debounce.read_ms()>175){ + led3=!led3; + debounce.reset(); //restart timer after toggle occurs + } + } //Function prototype for color selection function: int get_LCD_color(int color_integer); @@ -88,10 +97,15 @@ } int main(){ + + debounce.start(); //starts debounce timer + button.rise(&toggle); //toggles on button press + /* - logger1.attach(&pos_log1, LOG_UPDATE); - logger2.attach(&pos_log2, LOG_UPDATE); + logger1.attach(&pos_log1, LCD_UPDATE); + logger2.attach(&pos_log2, LCD_UPDATE); */ + // Initialize uLCD uLCD.baudrate(115200); uLCD.background_color(BLACK);