File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -20,22 +20,24 @@ float read_onboard_temperature(const char unit) {
20
20
/* 12-bit conversion, assume max value == ADC_VREF == 3.3 V */
21
21
const float conversionFactor = 3.3f / (1 << 12 );
22
22
23
- float adc = adc_read () * conversionFactor ;
24
- float tempC = 27.0 - (adc - 0.706 ) / 0.001721 ;
23
+ float adc = ( float ) adc_read () * conversionFactor ;
24
+ float tempC = 27.0f - (adc - 0.706f ) / 0.001721f ;
25
25
26
26
if (unit == 'C' ) {
27
27
return tempC ;
28
28
} else if (unit == 'F' ) {
29
29
return tempC * 9 / 5 + 32 ;
30
30
}
31
31
32
- return -1.0 ;
32
+ return -1.0f ;
33
33
}
34
34
35
35
int main () {
36
36
stdio_init_all ();
37
+ #ifdef PICO_DEFAULT_LED_PIN
37
38
gpio_init (PICO_DEFAULT_LED_PIN );
38
39
gpio_set_dir (PICO_DEFAULT_LED_PIN , GPIO_OUT );
40
+ #endif
39
41
40
42
/* Initialize hardware AD converter, enable onboard temperature sensor and
41
43
* select its channel (do this once for efficiency, but beware that this
@@ -48,10 +50,12 @@ int main() {
48
50
float temperature = read_onboard_temperature (TEMPERATURE_UNITS );
49
51
printf ("Onboard temperature = %.02f %c\n" , temperature , TEMPERATURE_UNITS );
50
52
53
+ #ifdef PICO_DEFAULT_LED_PIN
51
54
gpio_put (PICO_DEFAULT_LED_PIN , 1 );
52
55
sleep_ms (10 );
53
56
54
57
gpio_put (PICO_DEFAULT_LED_PIN , 0 );
58
+ #endif
55
59
sleep_ms (990 );
56
60
}
57
61
You can’t perform that action at this time.
0 commit comments