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.
Fork of TimeoutEx by
Diff: main.cpp
- Revision:
- 0:3151531e9a31
- Child:
- 1:2438293c128c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 06 21:08:45 2017 +0000 @@ -0,0 +1,33 @@ +/* + Project: TW_Ex_9_1 + File: main.cpp + + An example similar to T&W example 9.1. Green junction will flash + continuously. Blue junction will toggle in response to depressing the user + button. + + Created by Dr. C. S. Tritt + Last revised: 10/6/17 (v. 1.0) +*/ +#include "mbed.h" + +InterruptIn myButton(USER_BUTTON); // Button is normally high. Goes low w/press. + +DigitalOut bluLED(D4); // Bluee and green LED junctions. +DigitalOut grnLED(D3); + +void myISR() { // Simple ISR toggles the red LED junction when called. + bluLED = !bluLED; // Toggle blue junction. +} + +int main() { + bluLED = 0; // Turn blue & green off at start. + grnLED = 0; + + myButton.fall(&myISR); // "Register" the ISR routine. Sets vector. + + while(true) { + grnLED = !grnLED; // Toggle green junction. + wait(0.5); // Pause half a second. + } +} \ No newline at end of file