Charles Tritt / Mbed 2 deprecated TW_Ex_9_9

Dependencies:   mbed

Fork of TW_Ex_9_1 by Charles Tritt

Committer:
CSTritt
Date:
Mon Oct 09 03:03:12 2017 +0000
Revision:
1:c005988842c9
Parent:
0:3151531e9a31
Initial version. T & W Example 9.9

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 0:3151531e9a31 1 /*
CSTritt 1:c005988842c9 2 Project: TW_Ex_9_9
CSTritt 0:3151531e9a31 3 File: main.cpp
CSTritt 1:c005988842c9 4
CSTritt 1:c005988842c9 5 An example similar to T&W example 9.9. imple demo of "Ticker". Replicates
CSTritt 1:c005988842c9 6 behaviour of first led flashing program.
CSTritt 1:c005988842c9 7
CSTritt 1:c005988842c9 8 Modified by Dr. C. S. Tritt
CSTritt 1:c005988842c9 9 Last revised: 10/8/17 (v. 1.0)
CSTritt 0:3151531e9a31 10 */
CSTritt 1:c005988842c9 11
CSTritt 0:3151531e9a31 12 #include "mbed.h"
CSTritt 0:3151531e9a31 13
CSTritt 1:c005988842c9 14 void led_switch(void); // Ticker callback declaration.
CSTritt 1:c005988842c9 15 Ticker time_up; // Define a Ticker named "time_up."
CSTritt 1:c005988842c9 16 DigitalOut myled(D4); // Blue LED junction.
CSTritt 0:3151531e9a31 17
CSTritt 1:c005988842c9 18 int main(){
CSTritt 1:c005988842c9 19 time_up.attach(&led_switch, 0.2); // Initialize Ticker. 0.2 s interval.
CSTritt 1:c005988842c9 20 while(1) {} // Sit in a loop doing nothing, waiting for Ticker interrupt.
CSTritt 0:3151531e9a31 21 }
CSTritt 0:3151531e9a31 22
CSTritt 1:c005988842c9 23 void led_switch() { // Ticker callback.
CSTritt 1:c005988842c9 24 myled=!myled;
CSTritt 0:3151531e9a31 25 }