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@0:911c8f66a59d, 2021-03-23 (annotated)
- Committer:
- evamaffett
- Date:
- Tue Mar 23 21:56:15 2021 +0000
- Revision:
- 0:911c8f66a59d
- Child:
- 1:c9aa78523331
turn an LED light and speaker on and off.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| evamaffett | 0:911c8f66a59d | 1 | /* |
| evamaffett | 0:911c8f66a59d | 2 | * Lab #: |
| evamaffett | 0:911c8f66a59d | 3 | * Lab Title: |
| evamaffett | 0:911c8f66a59d | 4 | * Author(s): |
| evamaffett | 0:911c8f66a59d | 5 | * Date: |
| evamaffett | 0:911c8f66a59d | 6 | * Purpose: |
| evamaffett | 0:911c8f66a59d | 7 | */ |
| evamaffett | 0:911c8f66a59d | 8 | |
| evamaffett | 0:911c8f66a59d | 9 | #include "mbed.h" |
| evamaffett | 0:911c8f66a59d | 10 | #include "TTU_CSC1300.h" |
| evamaffett | 0:911c8f66a59d | 11 | |
| evamaffett | 0:911c8f66a59d | 12 | //FUNCTION PROTOTYPES GO HERE |
| evamaffett | 0:911c8f66a59d | 13 | |
| evamaffett | 0:911c8f66a59d | 14 | int main() |
| evamaffett | 0:911c8f66a59d | 15 | { |
| evamaffett | 0:911c8f66a59d | 16 | //this while(TRUE) loop keeps the program running |
| evamaffett | 0:911c8f66a59d | 17 | while(TRUE) |
| evamaffett | 0:911c8f66a59d | 18 | { |
| evamaffett | 0:911c8f66a59d | 19 | //WRITE SOLUTION HERE |
| evamaffett | 0:911c8f66a59d | 20 | float f_value = pot.read(); //f_value > 0.0f && f_value < 1.0f |
| evamaffett | 0:911c8f66a59d | 21 | f_value = (f_value * 25) + 20; |
| evamaffett | 0:911c8f66a59d | 22 | speaker = TRUE; //will turn the speaker on, sending a single square wave |
| evamaffett | 0:911c8f66a59d | 23 | wait_ms(250); //delays for 250 ms |
| evamaffett | 0:911c8f66a59d | 24 | speaker = FALSE; //will turn the speaker off |
| evamaffett | 0:911c8f66a59d | 25 | led0 = TRUE; |
| evamaffett | 0:911c8f66a59d | 26 | wait_ms(500); |
| evamaffett | 0:911c8f66a59d | 27 | led0 = FALSE; |
| evamaffett | 0:911c8f66a59d | 28 | wait_ms(500); |
| evamaffett | 0:911c8f66a59d | 29 | wait_ms(f_value); |
| evamaffett | 0:911c8f66a59d | 30 | } |
| evamaffett | 0:911c8f66a59d | 31 | } |