Mark Schwarzer / Mbed 2 deprecated Schwarzer_A3_1_Timers

Dependencies:   mbed

Committer:
markschwarzer
Date:
Tue Oct 06 14:35:03 2020 +0000
Revision:
1:60db0821e5bc
Parent:
0:5597320f2dba
Child:
2:1692cf4dda7f
initial imported code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markschwarzer 1:60db0821e5bc 1
slicht_instructor 0:5597320f2dba 2 //Blinks LED2 every 200ms using a single Timer object.
markschwarzer 1:60db0821e5bc 3
slicht_instructor 0:5597320f2dba 4
slicht_instructor 0:5597320f2dba 5 #include "mbed.h"
slicht_instructor 0:5597320f2dba 6
slicht_instructor 0:5597320f2dba 7 Timer timerLED2; //creat timer object
slicht_instructor 0:5597320f2dba 8 DigitalOut LEDOut2(LED2);
slicht_instructor 0:5597320f2dba 9
slicht_instructor 0:5597320f2dba 10 int main()
slicht_instructor 0:5597320f2dba 11 {
slicht_instructor 0:5597320f2dba 12 timerLED2.start(); //start timer counting
slicht_instructor 0:5597320f2dba 13
slicht_instructor 0:5597320f2dba 14 while(1) {
slicht_instructor 0:5597320f2dba 15 if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded
slicht_instructor 0:5597320f2dba 16 LEDOut2 = !LEDOut2;
slicht_instructor 0:5597320f2dba 17 timerLED2.reset(); //reset the timer back to zero
slicht_instructor 0:5597320f2dba 18 } //if timer
slicht_instructor 0:5597320f2dba 19
slicht_instructor 0:5597320f2dba 20 //if you had other code that you wanted to execute faster,
slicht_instructor 0:5597320f2dba 21 //you could put it here!
slicht_instructor 0:5597320f2dba 22
slicht_instructor 0:5597320f2dba 23 } //while
slicht_instructor 0:5597320f2dba 24 }