-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
33 lines (26 loc) · 1.02 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "mbed.h"
#include "N5110.h"
//Pin assignment format: lcd(IO, Ser_TX, Ser_RX, MOSI, SCLK, PWM)
N5110 lcd(PC_7, PA_9, PB_10, PB_5, PB_3, PA_10);
AnalogIn temp(PA_0);
char buffer[14] = {0};
float temp_reading, temp_sensor_vout, temperature;
float peak = 0.0;
int main(){
lcd.init(LPH7366_1);
while(1) {
temp_reading = temp.read(); //read the raw sensor output value (Between 0 and 1)
temp_sensor_vout = temp_reading * 3.3; //Convert the raw output into a output voltage
temperature = temp_sensor_vout * 100; //Convert the output voltage into a temperature reading, the sensor outputs 10mV per 'C therefore 260mv = 26'C
if(temperature > peak){
peak = temperature;
}
lcd.clear();
sprintf(buffer, "Temp: %.2f .C", temperature);
lcd.printString(buffer, 0, 1);
sprintf(buffer, "Peak: %.2f .C", peak);
lcd.printString(buffer, 0, 2);
lcd.refresh();
ThisThread::sleep_for(1s);
}
}