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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:bf24c62c6310
- Parent:
- 0:d2afa897dbc9
- Child:
- 2:928931868ac8
--- a/main.cpp Thu Nov 03 19:44:29 2016 +0000
+++ b/main.cpp Thu Nov 10 19:02:42 2016 +0000
@@ -1,12 +1,10 @@
#include "mbed.h"
+InterruptIn button(p18); // Interrupt on digital pushbutton input p18
+DigitalOut led1(p5); // digital out to p5
+void toggle(void); // function prototype
int main() {
-AnalogOut Aout(p18);
-while(1) {
-Aout=0.25; // 0.25*3.3V = 0.825V
-wait(0.1);
-Aout=0.5; // 0.5*3.3V = 1.65V
-wait(0.1);
-Aout=0.75; // 0.75*3.3V = 2.475V
-wait(0.1);
-}
+button.rise(&toggle); // attach the address of the toggle
+} // function to the rising edge
+void toggle() {
+led1=!led1;
}
\ No newline at end of file