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@1:4d134e02f836, 2020-11-30 (annotated)
- Committer:
- coltonbreeding
- Date:
- Mon Nov 30 23:31:33 2020 +0000
- Revision:
- 1:4d134e02f836
- Parent:
- 0:733cd53309ed
LED will blink
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| coltonbreeding | 0:733cd53309ed | 1 | /* |
| coltonbreeding | 1:4d134e02f836 | 2 | * Lab #: 3 |
| coltonbreeding | 1:4d134e02f836 | 3 | * Lab Title: Hardware 3 |
| coltonbreeding | 1:4d134e02f836 | 4 | * Author(s): Colton Breeding |
| coltonbreeding | 1:4d134e02f836 | 5 | * Date: 11/18/20 |
| coltonbreeding | 1:4d134e02f836 | 6 | * Purpose: Turn on the speaker and LED in an if then statment |
| coltonbreeding | 0:733cd53309ed | 7 | */ |
| coltonbreeding | 1:4d134e02f836 | 8 | |
| coltonbreeding | 0:733cd53309ed | 9 | #include "mbed.h" |
| coltonbreeding | 0:733cd53309ed | 10 | #include "TTU_CSC1300.h" |
| coltonbreeding | 1:4d134e02f836 | 11 | |
| coltonbreeding | 1:4d134e02f836 | 12 | AnalogIn pot(P0_11); |
| coltonbreeding | 1:4d134e02f836 | 13 | DigitalOut led(LED1); |
| coltonbreeding | 1:4d134e02f836 | 14 | |
| coltonbreeding | 0:733cd53309ed | 15 | int main() |
| coltonbreeding | 0:733cd53309ed | 16 | { |
| coltonbreeding | 1:4d134e02f836 | 17 | float ain; /* Variable to store the analog input*/ |
| coltonbreeding | 1:4d134e02f836 | 18 | |
| coltonbreeding | 1:4d134e02f836 | 19 | while(TRUE) |
| coltonbreeding | 0:733cd53309ed | 20 | { |
| coltonbreeding | 1:4d134e02f836 | 21 | ain = pot.read(); |
| coltonbreeding | 1:4d134e02f836 | 22 | (ain*25)+20; |
| coltonbreeding | 1:4d134e02f836 | 23 | if(SW5 = TRUE && ain > 35) |
| coltonbreeding | 1:4d134e02f836 | 24 | { |
| coltonbreeding | 1:4d134e02f836 | 25 | LED0 = TRUE |
| coltonbreeding | 1:4d134e02f836 | 26 | speaker = TRUE; |
| coltonbreeding | 1:4d134e02f836 | 27 | wait_ms(10); |
| coltonbreeding | 1:4d134e02f836 | 28 | LED0 = FALSE |
| coltonbreeding | 1:4d134e02f836 | 29 | speaker = FALSE; |
| coltonbreeding | 1:4d134e02f836 | 30 | wait_ms(ain); |
| coltonbreeding | 1:4d134e02f836 | 31 | } |
| coltonbreeding | 1:4d134e02f836 | 32 | else if(SW4 = TRUE) |
| coltonbreeding | 1:4d134e02f836 | 33 | { |
| coltonbreeding | 1:4d134e02f836 | 34 | LED0 = TRUE |
| coltonbreeding | 1:4d134e02f836 | 35 | speaker = TRUE; |
| coltonbreeding | 1:4d134e02f836 | 36 | wait_ms(10); |
| coltonbreeding | 1:4d134e02f836 | 37 | LED0 = FALSE |
| coltonbreeding | 1:4d134e02f836 | 38 | speaker = FALSE; |
| coltonbreeding | 1:4d134e02f836 | 39 | wait_ms(ain); |
| coltonbreeding | 1:4d134e02f836 | 40 | } |
| coltonbreeding | 1:4d134e02f836 | 41 | else |
| coltonbreeding | 1:4d134e02f836 | 42 | { |
| coltonbreeding | 1:4d134e02f836 | 43 | speaker = TRUE; |
| coltonbreeding | 1:4d134e02f836 | 44 | wait_ms(10); |
| coltonbreeding | 1:4d134e02f836 | 45 | speaker = FALSE; |
| coltonbreeding | 1:4d134e02f836 | 46 | wait_ms(ain); |
| coltonbreeding | 1:4d134e02f836 | 47 | } |
| coltonbreeding | 1:4d134e02f836 | 48 | |
| coltonbreeding | 1:4d134e02f836 | 49 | } |
| coltonbreeding | 1:4d134e02f836 | 50 | |
| coltonbreeding | 1:4d134e02f836 | 51 | |
| coltonbreeding | 0:733cd53309ed | 52 | } |