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
main.cpp
- Committer:
- conner_sanders
- Date:
- 2021-04-10
- Revision:
- 0:abd4bce612ec
- Child:
- 1:4e747357be1d
File content as of revision 0:abd4bce612ec:
/*
 *     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;
        }
    }   
}