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: SDFileSystem mbed
Fork of shomberg_hw_6 by
main.cpp
- Committer:
- rshomberg
- Date:
- 2018-10-25
- Revision:
- 9:da0b72918880
- Parent:
- 8:d6560caeda9a
- Child:
- 10:c9a438114fbd
File content as of revision 9:da0b72918880:
/**
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 "OCE360Input.h"
#include "SegDisplay.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);
}
}
