Russell Shomberg
/
shomberg_hw_6
HW6 for OCE560
Fork of shomberg_hw_5 by
main.cpp
- Committer:
- rshomberg
- Date:
- 2018-10-25
- Revision:
- 11:42914083ac70
- Parent:
- 10:c9a438114fbd
- Child:
- 12:ea407dcaff78
File content as of revision 11:42914083ac70:
/** Temperature Sensor for hw6 main.cpp Purpose: Read signal from TMP36 connected to pin20 Display output voltage to terminal Display difference in mV of output voltage to starting voltage on 2x 7-Segment Displays See outputs for pin configuration Toggle switch connected to pin07 to convert displays to degC @author Russell Shomberg @created 2018-10-23 @revised 2018-10-25 @version 0.0 Issues: No Decimal point for temperature */ // INCLUDES #include "mbed.h" #include "SegDisplay.h" #include "OCE360Input.h" // OUTPUTS Serial pc(USBTX, USBRX); // for debugging // VARIABLES int outputT= 0; float v0; float deltav; float val; int ones; int tens; int main() { // read starting voltage from temperature sensor v0 = read_sensor(); while(1) { // Read Switch if on output temp else output mV outputT = read_switch(); deltav = read_sensor()-v0; // Output to terminal if (outputT) { // Convert to temp val = convert_mV_to_temp(deltav); //printf("Temperature Difference = %1.2f degC\n\r", val); } else { val = deltav; //printf("Voltage Difference = %1.2f mV\n\r", val); } // Convert val to ones and tens char ones = fmod(rint(val),10); tens = fmod(rint(val) / 10, 10); Seg1 = SegConvert(ones); Seg2 = SegConvert(tens); wait(1); } }