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.
Dependencies: mbed TTU_CSC1300
Diff: main.cpp
- Revision:
- 0:abd4bce612ec
- Child:
- 1:4e747357be1d
diff -r 000000000000 -r abd4bce612ec main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Apr 10 21:22:50 2021 +0000
@@ -0,0 +1,47 @@
+/*
+ * Lab #: 3
+ * Lab Title: Conditional Statements
+ * Author(s): Conner Sanders
+ * Date: 04/10/21
+ * Purpose: use conditionals to toggle LED0
+ */
+
+#include "mbed.h"
+#include "TTU_CSC1300.h"
+
+int main()
+{
+ //led0 flashes with a delay of 10 ms
+ led0 = TRUE;
+ wait_ms(10);
+ led0 = FALSE;
+
+ //speaker beeps with a delay of 10 ms
+ speaker = TRUE;
+ wait_ms(10);
+ speaker = FALSE;
+
+ while(TRUE){
+
+ float potVolt = pot.read();
+ float delay = (potVolt * 25.0) + 20.0;
+ bool sw5_pressed = sw5;
+ bool sw4_pressed = sw4;
+ if(sw5_pressed && delay > 35 || sw4_pressed){
+ //led0 flashes with a delay related to the voltage readings of potentiometer
+ led0 = TRUE;
+ wait_ms(delay);
+ led0 = FALSE;
+ wait_ms(delay);
+
+ //speaker beeps with a delay related to the voltage readings of poteniometer
+ speaker = TRUE;
+ wait_ms(delay);
+ speaker = FALSE;
+ }else{
+ speaker = TRUE;
+ wait_ms(delay);
+ speaker = FALSE;
+ }
+ }
+}