by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Fri May 24 21:49:51 2013 +0000
Revision:
0:f604cd45b955
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:f604cd45b955 1 /* Program Example 9.11: Toggles LED1 every time p18 goes high. Uses hardware build shown in Figure 9.3.
robt 0:f604cd45b955 2 */
robt 0:f604cd45b955 3 #include "mbed.h"
robt 0:f604cd45b955 4 InterruptIn button(p5); // Interrupt on digital pushbutton input p18
robt 0:f604cd45b955 5 DigitalOut led1(LED1); // mbed LED1
robt 0:f604cd45b955 6 void toggle(void); // function prototype
robt 0:f604cd45b955 7
robt 0:f604cd45b955 8 int main() {
robt 0:f604cd45b955 9 button.rise(&toggle); // attach the address of the toggle
robt 0:f604cd45b955 10 } // function to the rising edge
robt 0:f604cd45b955 11
robt 0:f604cd45b955 12 void toggle() {
robt 0:f604cd45b955 13 led1=!led1;
robt 0:f604cd45b955 14 }
robt 0:f604cd45b955 15