Implement a SD card into HW6
Dependencies: SDFileSystem mbed
Fork of shomberg_hw_6 by
main.cpp@12:ea407dcaff78, 2018-10-25 (annotated)
- Committer:
- rshomberg
- Date:
- Thu Oct 25 22:43:36 2018 +0000
- Revision:
- 12:ea407dcaff78
- Parent:
- 11:42914083ac70
- Child:
- 18:699b41309be7
made SegWrite function and moved pin assignments to header files. This does not work.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rshomberg | 0:82635173a413 | 1 | /** |
rshomberg | 8:d6560caeda9a | 2 | Temperature Sensor for hw6 |
rshomberg | 0:82635173a413 | 3 | main.cpp |
rshomberg | 0:82635173a413 | 4 | |
rshomberg | 6:8cfa0216554f | 5 | Purpose: Read signal from TMP36 connected to pin20 |
rshomberg | 6:8cfa0216554f | 6 | Display output voltage to terminal |
rshomberg | 6:8cfa0216554f | 7 | Display difference in mV of output voltage to starting voltage on 2x 7-Segment Displays |
rshomberg | 6:8cfa0216554f | 8 | See outputs for pin configuration |
rshomberg | 6:8cfa0216554f | 9 | Toggle switch connected to pin07 to convert displays to degC |
rshomberg | 6:8cfa0216554f | 10 | |
rshomberg | 8:d6560caeda9a | 11 | @author Russell Shomberg |
rshomberg | 8:d6560caeda9a | 12 | @created 2018-10-23 |
rshomberg | 9:da0b72918880 | 13 | @revised 2018-10-25 |
rshomberg | 8:d6560caeda9a | 14 | @version 0.0 |
rshomberg | 0:82635173a413 | 15 | |
rshomberg | 6:8cfa0216554f | 16 | Issues: No Decimal point for temperature |
rshomberg | 7:1a43ff8ccc08 | 17 | |
rshomberg | 5:dbd163551a58 | 18 | */ |
rshomberg | 0:82635173a413 | 19 | |
rshomberg | 0:82635173a413 | 20 | // INCLUDES |
rshomberg | 0:82635173a413 | 21 | #include "mbed.h" |
rshomberg | 11:42914083ac70 | 22 | #include "SegDisplay.h" |
rshomberg | 9:da0b72918880 | 23 | #include "OCE360Input.h" |
rshomberg | 0:82635173a413 | 24 | |
rshomberg | 0:82635173a413 | 25 | // OUTPUTS |
rshomberg | 2:312a0a9c4485 | 26 | Serial pc(USBTX, USBRX); // for debugging |
rshomberg | 6:8cfa0216554f | 27 | |
rshomberg | 0:82635173a413 | 28 | // VARIABLES |
rshomberg | 6:8cfa0216554f | 29 | int outputT= 0; |
rshomberg | 6:8cfa0216554f | 30 | float v0; |
rshomberg | 6:8cfa0216554f | 31 | float deltav; |
rshomberg | 6:8cfa0216554f | 32 | float val; |
rshomberg | 6:8cfa0216554f | 33 | |
rshomberg | 0:82635173a413 | 34 | |
rshomberg | 0:82635173a413 | 35 | int main() { |
rshomberg | 6:8cfa0216554f | 36 | // read starting voltage from temperature sensor |
rshomberg | 9:da0b72918880 | 37 | v0 = read_sensor(); |
rshomberg | 6:8cfa0216554f | 38 | |
rshomberg | 0:82635173a413 | 39 | while(1) { |
rshomberg | 6:8cfa0216554f | 40 | // Read Switch if on output temp else output mV |
rshomberg | 9:da0b72918880 | 41 | outputT = read_switch(); |
rshomberg | 9:da0b72918880 | 42 | deltav = read_sensor()-v0; |
rshomberg | 1:cbee04784c60 | 43 | |
rshomberg | 6:8cfa0216554f | 44 | // Output to terminal |
rshomberg | 6:8cfa0216554f | 45 | if (outputT) { |
rshomberg | 6:8cfa0216554f | 46 | // Convert to temp |
rshomberg | 9:da0b72918880 | 47 | val = convert_mV_to_temp(deltav); |
rshomberg | 9:da0b72918880 | 48 | //printf("Temperature Difference = %1.2f degC\n\r", val); |
rshomberg | 6:8cfa0216554f | 49 | } |
rshomberg | 6:8cfa0216554f | 50 | |
rshomberg | 6:8cfa0216554f | 51 | else { |
rshomberg | 6:8cfa0216554f | 52 | val = deltav; |
rshomberg | 9:da0b72918880 | 53 | //printf("Voltage Difference = %1.2f mV\n\r", val); |
rshomberg | 6:8cfa0216554f | 54 | } |
rshomberg | 4:098e3d869055 | 55 | |
rshomberg | 12:ea407dcaff78 | 56 | SegWrite(val); |
rshomberg | 12:ea407dcaff78 | 57 | |
rshomberg | 6:8cfa0216554f | 58 | wait(1); |
rshomberg | 6:8cfa0216554f | 59 | |
rshomberg | 0:82635173a413 | 60 | } |
rshomberg | 6:8cfa0216554f | 61 | |
rshomberg | 0:82635173a413 | 62 | } |
rshomberg | 6:8cfa0216554f | 63 |