Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Assignment3_1.cpp
- Committer:
- michael_antonucci
- Date:
- 2022-10-14
- Revision:
- 2:4224d5ca4f2d
File content as of revision 2:4224d5ca4f2d:
//Code for Assignment 3.1
//Blinks LED2 every 200ms and LED3 every 400ms using two Timer objects.
//Created: M. Antonucci 10/11/22(edited version of S. Licht's code)
#include "mbed.h"
Timer timerLED2; //creat timer object
Timer timerLED3;
DigitalOut LEDOut2(LED2);
DigitalOut LEDOut3(LED3);
int main()
{
timerLED2.start(); //start timer counting on the LED2 timer
timerLED3.start(); //start timer counting on the LED3 timer
while(1) {
if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded
LEDOut2 = !LEDOut2;
timerLED2.reset(); //reset the timer2 back to zero
} //if timer
if (timerLED3.read_ms()>=400) {
LEDOut3 = !LEDOut3;
timerLED3.reset(); //reset the timer3 back to zero
}
//if you had other code that you wanted to execute faster,
//you could put it here!
} //while
}