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:
- coltonbreeding
- Date:
- 2020-11-30
- Revision:
- 1:4d134e02f836
- Parent:
- 0:733cd53309ed
File content as of revision 1:4d134e02f836:
/*
* 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"
AnalogIn pot(P0_11);
DigitalOut led(LED1);
int main()
{
float ain; /* Variable to store the analog input*/
while(TRUE)
{
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);
}
}
}