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:6b2314a40652
- Child:
- 1:fdcb0bfe75b7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 12 23:21:55 2020 +0000 @@ -0,0 +1,34 @@ +//Mark Schwarzer Assignment 4 + +#include "mbed.h" + +Ticker tickerLED1; //creat ticker object +Ticker tickerLED3; +DigitalOut LEDOut1(LED1); +DigitalOut LEDOut3(LED3); +InterruptIn button(p18); +Timer debounce; + +void toggle(void); + +int main() { + debounce.start(); + button.rise(&toggle); //toggle function to rising edge +} +void toggle() { + if (debounce.read_ms()>200); //allow toggle if debounce timer has passed 200 ms + LEDOut1 = !LEDOut1; + debounce.reset(); //restart timer at toggle + + +} +void changeLED1() //the function that will be called by the ticker object. +{ + LEDOut1 = !LEDOut1; +} +void changeLED3() //function called for other ticker object LED3 +{ + LEDOut3 = !LEDOut3; +} + +