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:070bf82cd6f3, 2020-11-29 (annotated)
- Committer:
- gavinshelton1
- Date:
- Sun Nov 29 20:53:38 2020 +0000
- Revision:
- 0:070bf82cd6f3
This program reads and stores current percentages
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gavinshelton1 | 0:070bf82cd6f3 | 1 | /* |
| gavinshelton1 | 0:070bf82cd6f3 | 2 | * Lab #: 3 |
| gavinshelton1 | 0:070bf82cd6f3 | 3 | * Lab Title: Hardware Lab 3 |
| gavinshelton1 | 0:070bf82cd6f3 | 4 | * Author(s): Gavin Shelton |
| gavinshelton1 | 0:070bf82cd6f3 | 5 | * Date: 11-29-2020 |
| gavinshelton1 | 0:070bf82cd6f3 | 6 | * Purpose: Using the Potentiometer and Utilizing Conditional Statments |
| gavinshelton1 | 0:070bf82cd6f3 | 7 | */ |
| gavinshelton1 | 0:070bf82cd6f3 | 8 | |
| gavinshelton1 | 0:070bf82cd6f3 | 9 | #include "mbed.h" |
| gavinshelton1 | 0:070bf82cd6f3 | 10 | #include "TTU_CSC1300.h" |
| gavinshelton1 | 0:070bf82cd6f3 | 11 | |
| gavinshelton1 | 0:070bf82cd6f3 | 12 | //FUNCTION PROTOTYPES GO HERE |
| gavinshelton1 | 0:070bf82cd6f3 | 13 | |
| gavinshelton1 | 0:070bf82cd6f3 | 14 | TextLCD lcd(TextLCD::LCD_CURSOR_ON_BLINKING_ON); |
| gavinshelton1 | 0:070bf82cd6f3 | 15 | |
| gavinshelton1 | 0:070bf82cd6f3 | 16 | int main() |
| gavinshelton1 | 0:070bf82cd6f3 | 17 | { |
| gavinshelton1 | 0:070bf82cd6f3 | 18 | //this while(TRUE) loop keeps the program running |
| gavinshelton1 | 0:070bf82cd6f3 | 19 | |
| gavinshelton1 | 0:070bf82cd6f3 | 20 | float f_value = pot.read(); |
| gavinshelton1 | 0:070bf82cd6f3 | 21 | bool sw5_pressed = sw5; |
| gavinshelton1 | 0:070bf82cd6f3 | 22 | bool sw4_pressed = sw4; |
| gavinshelton1 | 0:070bf82cd6f3 | 23 | |
| gavinshelton1 | 0:070bf82cd6f3 | 24 | f_value = (f_value * 25) + 20; |
| gavinshelton1 | 0:070bf82cd6f3 | 25 | |
| gavinshelton1 | 0:070bf82cd6f3 | 26 | |
| gavinshelton1 | 0:070bf82cd6f3 | 27 | if ((sw5_pressed == TRUE) && (f_value > 35)) { |
| gavinshelton1 | 0:070bf82cd6f3 | 28 | |
| gavinshelton1 | 0:070bf82cd6f3 | 29 | led0 = TRUE; |
| gavinshelton1 | 0:070bf82cd6f3 | 30 | speaker = TRUE; |
| gavinshelton1 | 0:070bf82cd6f3 | 31 | wait_ms(f_value); |
| gavinshelton1 | 0:070bf82cd6f3 | 32 | led0 = FALSE; |
| gavinshelton1 | 0:070bf82cd6f3 | 33 | speaker = FALSE; |
| gavinshelton1 | 0:070bf82cd6f3 | 34 | |
| gavinshelton1 | 0:070bf82cd6f3 | 35 | } |
| gavinshelton1 | 0:070bf82cd6f3 | 36 | else if (sw4_pressed == TRUE) { |
| gavinshelton1 | 0:070bf82cd6f3 | 37 | |
| gavinshelton1 | 0:070bf82cd6f3 | 38 | led0 = TRUE; |
| gavinshelton1 | 0:070bf82cd6f3 | 39 | speaker = TRUE; |
| gavinshelton1 | 0:070bf82cd6f3 | 40 | wait_ms(f_value); |
| gavinshelton1 | 0:070bf82cd6f3 | 41 | led0 = FALSE; |
| gavinshelton1 | 0:070bf82cd6f3 | 42 | speaker = FALSE; |
| gavinshelton1 | 0:070bf82cd6f3 | 43 | |
| gavinshelton1 | 0:070bf82cd6f3 | 44 | } |
| gavinshelton1 | 0:070bf82cd6f3 | 45 | else { |
| gavinshelton1 | 0:070bf82cd6f3 | 46 | |
| gavinshelton1 | 0:070bf82cd6f3 | 47 | speaker = TRUE; |
| gavinshelton1 | 0:070bf82cd6f3 | 48 | wait_ms(f_value); |
| gavinshelton1 | 0:070bf82cd6f3 | 49 | speaker = FALSE; |
| gavinshelton1 | 0:070bf82cd6f3 | 50 | |
| gavinshelton1 | 0:070bf82cd6f3 | 51 | } |
| gavinshelton1 | 0:070bf82cd6f3 | 52 | |
| gavinshelton1 | 0:070bf82cd6f3 | 53 | } |