Finalized Code for Assignment 1: Lucy Damon

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lucydamon
Date:
Tue Sep 27 13:11:55 2022 +0000
Commit message:
Finalized working assignment 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 27 13:11:55 2022 +0000
@@ -0,0 +1,76 @@
+#include "mbed.h"
+
+
+//Lucy Damon Assignment 1
+
+//The purpose of this assignment is to utilize a for loop to activate different cases.
+
+
+
+
+
+
+Serial pc(USBTX, USBRX);
+
+
+DigitalOut myled(LED1);
+
+int main()
+{
+
+    float a;
+
+    for (int n=1; n<6; n++) {      //==> [(i=1) initialization] [(i++)= i+1)] [i<6 = loop condition/stop condition] as long as i is less than 6, it will execute this for loop.
+        a = (float) n;
+
+
+
+        switch (n) {
+            case 1:
+                pc.printf("a=%f ; minimum\r\n",a);//code to be executed if n=1
+                wait(2);
+
+                break;
+            case 2:
+                pc.printf("a=%f ; low\r\n",a);//code to be executed if n=2
+
+                wait(2);
+
+                break;
+
+
+            case 3:
+                pc.printf("a=%f ; medium\r\n",a);//code to be executed if n=2
+                wait(2);
+
+                break;
+            case 4:
+                pc.printf("a=%f ; high\r\n",a);//code to be executed if n=2
+                wait(2);
+
+                break;
+            case 5:
+                pc.printf("a=%f ; maximum\r\n",a);//code to be executed if n=2
+                wait(2);
+
+                break;
+            default:
+                pc.printf("you failed the assignment\r\n");//code to be executed if n doesnt match above statements
+
+        }
+
+
+
+
+
+
+    }
+
+
+
+}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 27 13:11:55 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file