megan gimple / Mbed 2 deprecated gimple_A3_1_Ticker

Dependencies:   mbed

Committer:
slicht_instructor
Date:
Sun Oct 04 16:23:47 2020 +0000
Revision:
1:76d11e984b8d
Parent:
0:5597320f2dba
Child:
3:f6547e1c1dfc
Assignment 3.2 base code, blinks LED2 every 200ms using a single Ticker object.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
slicht_instructor 1:76d11e984b8d 1 //Base code for modification for Assignment 3.2
slicht_instructor 1:76d11e984b8d 2 //Blinks LED2 every 200ms using a single Ticker object.
slicht_instructor 0:5597320f2dba 3 //Created: S. Licht, 10/04/2020
slicht_instructor 1:76d11e984b8d 4 #include "mbed.h"
slicht_instructor 1:76d11e984b8d 5 Ticker tickerLED2; //creat ticker object
slicht_instructor 1:76d11e984b8d 6 DigitalOut LEDOut2(LED2);
slicht_instructor 0:5597320f2dba 7
slicht_instructor 1:76d11e984b8d 8 void changeLED2() //the function that will be called by the ticker object.
slicht_instructor 1:76d11e984b8d 9 {
slicht_instructor 1:76d11e984b8d 10 LEDOut2 = !LEDOut2;
slicht_instructor 1:76d11e984b8d 11 }
slicht_instructor 0:5597320f2dba 12
slicht_instructor 0:5597320f2dba 13 int main()
slicht_instructor 0:5597320f2dba 14 {
slicht_instructor 1:76d11e984b8d 15 tickerLED2.attach(&changeLED2,0.2); //the address of the function to call
slicht_instructor 1:76d11e984b8d 16 //and the interval in seconds between
slicht_instructor 1:76d11e984b8d 17 //calls to that function
slicht_instructor 0:5597320f2dba 18
slicht_instructor 0:5597320f2dba 19 while(1) {
slicht_instructor 1:76d11e984b8d 20 wait(0.1);
slicht_instructor 1:76d11e984b8d 21 wait(0.1);
slicht_instructor 1:76d11e984b8d 22 wait(0.1);
slicht_instructor 1:76d11e984b8d 23 wait(0.1);
slicht_instructor 1:76d11e984b8d 24 wait(0.1);
slicht_instructor 1:76d11e984b8d 25 //the main loop is spinning every 500ms, but the LED needs to go faster!
slicht_instructor 0:5597320f2dba 26 } //while
slicht_instructor 0:5597320f2dba 27 }