Rob Toulson / Mbed 2 deprecated PE_09-11_LEDToggle

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 9.11: Toggles LED1 every time p18 goes high. Uses hardware build shown in Figure 9.3.
00002                                                                          */
00003 #include "mbed.h"
00004 InterruptIn button(p5);     // Interrupt on digital pushbutton input p18 
00005 DigitalOut led1(LED1);       // mbed LED1
00006 void toggle(void);           // function prototype
00007 
00008 int main() {
00009   button.rise(&toggle);                   // attach the address of the toggle
00010 }                                         // function to the rising edge 
00011 
00012 void toggle() {
00013   led1=!led1;
00014 }
00015