Eva Maffett / Mbed 2 deprecated EduBaseV3_Lab3

Dependencies:   mbed TTU_CSC1300

Files at this revision

API Documentation at this revision

Comitter:
evamaffett
Date:
Tue Apr 13 03:36:17 2021 +0000
Commit message:
conditional statements

Changed in this revision

TTU_CSC1300.lib Show annotated file Show diff for this revision Revisions of this file
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/TTU_CSC1300.lib	Tue Apr 13 03:36:17 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/jwbruce/code/TTU_CSC1300/#7bb32dea705b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 13 03:36:17 2021 +0000
@@ -0,0 +1,45 @@
+
+ *     Lab #: 3
+ * Lab Title: Conditional Statements
+ * Author(s): Eva Maffett
+ *      Date: 4-12-2021
+ *   Purpose: Use conditional branching to control speaker and LED outputs
+ */
+
+#include "mbed.h"
+#include "TTU_CSC1300.h"
+
+//FUNCTION PROTOTYPES GO HERE
+
+int main()
+{
+    //this while(TRUE) loop keeps the program running
+    while(TRUE)
+    {
+        //WRITE SOLUTION HERE
+        float f_value = pot.read(); //f_value > 0.0f && f_value < 1.0f
+        f_value = (f_value * 25) + 20;
+        if (bool sw5_pressed = TRUE && f_value > 35){
+            speaker = TRUE;  //will turn the speaker on, sending a single square wave
+            wait_ms(250);    //delays for 250 ms
+            speaker = FALSE; //will turn the speaker off
+            led0 = TRUE;
+            wait_ms(500);
+            led0 = FALSE;
+            wait_ms(500);
+            wait_ms(f_value);   
+        } else if (bool sw4_pressed = TRUE){
+            speaker = TRUE;  //will turn the speaker on, sending a single square wave
+            wait_ms(250);    //delays for 250 ms
+            speaker = FALSE; //will turn the speaker off
+            led0 = TRUE;
+            wait_ms(500);
+            led0 = FALSE;
+            wait_ms(500);
+            wait_ms(f_value); 
+        } else {
+            speaker = TRUE;
+            wait_ms(f_value);   
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 13 03:36:17 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file