Colton breeding / Mbed 2 deprecated CSC1300_EduBaseV2_Lab0

Dependencies:   mbed TTU_CSC1300

Files at this revision

API Documentation at this revision

Comitter:
coltonbreeding
Date:
Mon Nov 30 23:31:33 2020 +0000
Parent:
0:733cd53309ed
Commit message:
LED will blink

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Nov 04 04:32:20 2020 +0000
+++ b/main.cpp	Mon Nov 30 23:31:33 2020 +0000
@@ -1,25 +1,52 @@
 /*
- *     Lab #:
- * Lab Title:
- * Author(s):
- *      Date:
- *   Purpose:
+ *     Lab #: 3
+ * Lab Title: Hardware 3
+ * Author(s): Colton Breeding 
+ *      Date:  11/18/20
+ *   Purpose: Turn on the speaker and LED in an if then statment
  */
-
+ 
 #include "mbed.h"
 #include "TTU_CSC1300.h"
-
-//FUNCTION PROTOTYPES GO HERE
-TextLCD lcd(TextLCD::LCD_CURSOR_ON_BLINKING_ON);
+ 
+AnalogIn pot(P0_11); 
+DigitalOut led(LED1); 
+ 
 int main()
 {
-    //this while(TRUE) loop keeps the program running
-    while(TRUE)
+    float ain;   /* Variable to store the analog input*/
+ 
+    while(TRUE) 
     {
-        //WRITE SOLUTION HERE
- //blinks "Hello, World!" every other second
-lcd.printf("Hello, World!");
-wait_ms(1000);
-lcd.cls();
-wait_ms(1000);   }
+        ain = pot.read();
+        (ain*25)+20;
+        if(SW5 = TRUE && ain > 35)
+        {
+            LED0 = TRUE
+            speaker = TRUE;  
+            wait_ms(10);    
+            LED0 = FALSE
+            speaker = FALSE;
+            wait_ms(ain);
+        }
+        else if(SW4 = TRUE)
+        {
+            LED0 = TRUE
+            speaker = TRUE;  
+            wait_ms(10);    
+            LED0 = FALSE
+            speaker = FALSE;
+            wait_ms(ain);
+        }
+        else
+        {
+            speaker = TRUE;  
+            wait_ms(10);    
+            speaker = FALSE;
+            wait_ms(ain);
+        }
+                 
+    }
+ 
+    
 }
\ No newline at end of file