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-12
- Revision:
- 2:b46e9d2446cc
- Parent:
- 1:4e747357be1d
- Child:
- 3:0de5da8ecede
File content as of revision 2:b46e9d2446cc:
/*
* 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()
{
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 and speaker flash/beep with a delay related to potentiometer reading
led0 = TRUE;
speaker = TRUE;
wait_ms(delay);
led0 = FALSE;
speaker = FALSE;
wait_ms(delay);
}else{
//speaker only beeps with delay related to potentiometer reading
speaker = TRUE;
wait_ms(delay);
speaker = FALSE;
wait_ms(delay);
}
}
}