Colby Adams / Mbed 2 deprecated EduBaseV2_Lab3

Dependencies:   mbed TTU_CSC1300

Committer:
kingcolba
Date:
Fri Apr 09 20:10:04 2021 +0000
Revision:
0:2795fb9c6557
Lab3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kingcolba 0:2795fb9c6557 1 /*
kingcolba 0:2795fb9c6557 2 * Lab #: 3
kingcolba 0:2795fb9c6557 3 * Lab Title: Reading and Processing Analog Inputs
kingcolba 0:2795fb9c6557 4 * Author(s): Colby Adams
kingcolba 0:2795fb9c6557 5 * Date: 5 April 2021
kingcolba 0:2795fb9c6557 6 * Purpose: Conditional Statements
kingcolba 0:2795fb9c6557 7 */
kingcolba 0:2795fb9c6557 8
kingcolba 0:2795fb9c6557 9 #include "mbed.h"
kingcolba 0:2795fb9c6557 10 #include "TTU_CSC1300.h"
kingcolba 0:2795fb9c6557 11
kingcolba 0:2795fb9c6557 12 //FUNCTION PROTOTYPES GO HERE
kingcolba 0:2795fb9c6557 13 TextLCD lcd(TextLCD::LCD_CURSOR_ON_BLINKING_ON);
kingcolba 0:2795fb9c6557 14
kingcolba 0:2795fb9c6557 15 int main(){
kingcolba 0:2795fb9c6557 16 //this while(TRUE) loop keeps the program running
kingcolba 0:2795fb9c6557 17 while(TRUE){
kingcolba 0:2795fb9c6557 18
kingcolba 0:2795fb9c6557 19 float f_value = pot.read(); //f_value > 0.0f && f_value < 1.0f
kingcolba 0:2795fb9c6557 20 float timer = (f_value * 25) + 20;
kingcolba 0:2795fb9c6557 21
kingcolba 0:2795fb9c6557 22 if ((sw5 == true && timer > 35) || sw4 == true){
kingcolba 0:2795fb9c6557 23 if (led0 == false){
kingcolba 0:2795fb9c6557 24 speaker = true;
kingcolba 0:2795fb9c6557 25 led0 = true;
kingcolba 0:2795fb9c6557 26 } else if (led0 == true){
kingcolba 0:2795fb9c6557 27 led0 = false;
kingcolba 0:2795fb9c6557 28 speaker = true;
kingcolba 0:2795fb9c6557 29 }
kingcolba 0:2795fb9c6557 30 } else {
kingcolba 0:2795fb9c6557 31 if (speaker == true){
kingcolba 0:2795fb9c6557 32 speaker = false;
kingcolba 0:2795fb9c6557 33 } else if (speaker == false){
kingcolba 0:2795fb9c6557 34 speaker = true;
kingcolba 0:2795fb9c6557 35 }
kingcolba 0:2795fb9c6557 36 }
kingcolba 0:2795fb9c6557 37 }
kingcolba 0:2795fb9c6557 38 }