Mark Schwarzer / Mbed 2 deprecated Schwarzer_A3_1_Timers

Dependencies:   mbed

Committer:
slicht_instructor
Date:
Sun Oct 04 15:50:17 2020 +0000
Revision:
0:5597320f2dba
Child:
1:60db0821e5bc
Base code for Assignment 2.1 in OCE360. Blinks LED2 every 200ms using a single timer object.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
slicht_instructor 0:5597320f2dba 1 //Base code for modification for Assignment 2.1
slicht_instructor 0:5597320f2dba 2 //Blinks LED2 every 200ms using a single Timer object.
slicht_instructor 0:5597320f2dba 3 //Created: S. Licht, 10/04/2020
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 }