Assignment3.1 code. Fully functional code. GRADE THIS

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
michael_antonucci
Date:
Fri Oct 14 13:18:51 2022 +0000
Parent:
1:3cadb8807520
Commit message:
Working timer code. Grade This

Changed in this revision

A3_1_Single_Timer.lib Show diff for this revision Revisions of this file
Assignment3_1.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
--- a/A3_1_Single_Timer.lib	Thu Oct 07 12:04:46 2021 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/slicht_instructor/code/A3_1_Single_Timer/#5597320f2dba
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Assignment3_1.cpp	Fri Oct 14 13:18:51 2022 +0000
@@ -0,0 +1,30 @@
+//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
+}
--- a/main.cpp	Thu Oct 07 12:04:46 2021 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-//Base code for modification for Assignment 2.2
-//Blinks LED2 every 200ms using a single Timer object.
-//Created: S. Licht, 10/04/2020
-
-#include "mbed.h"
-
-Timer timerLED2;  //creat timer object
-DigitalOut LEDOut2(LED2);
-
-int main()
-{
-    timerLED2.start(); //start timer counting
-
-    while(1) {
-        if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded
-            LEDOut2 = !LEDOut2;
-            timerLED2.reset();  //reset the timer back to zero
-        }  //if timer
-
-        //if you had other code that you wanted to execute faster,
-        //you could put it here!
-        
-    } //while
-}