Skip to content
Snippets Groups Projects
Commit 6202c757 authored by abp1g20's avatar abp1g20
Browse files

Replace main.c

parent cff37216
No related branches found
No related tags found
No related merge requests found
...@@ -33,11 +33,11 @@ int main() { ...@@ -33,11 +33,11 @@ int main() {
//Update temperature display every second //Update temperature display every second
//Infinite loop //Infinite loop
while(1) { while (1) {
uint16_t raw = adc_read(); //Define a variable to store the raw output value from the adc uint16_t raw = adc_read(); //Define a variable to store the raw output value from the adc
//Do the conversion //Do the conversion
const float conversion = 3.3f / (1<<12); const float conversion = 3.3f / (1 << 12);
float voltage = raw * conversion; // convert raw value to voltage float voltage = raw * conversion; // convert raw value to voltage
float temperature = 27 - (voltage - 0.706) / 0.001721; // convert voltage to temperature value float temperature = 27 - (voltage - 0.706) / 0.001721; // convert voltage to temperature value
...@@ -52,3 +52,4 @@ int main() { ...@@ -52,3 +52,4 @@ int main() {
//wait 1 sec //wait 1 sec
sleep_ms(1000); sleep_ms(1000);
} }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment