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) {
2020 /* 12-bit conversion, assume max value == ADC_VREF == 3.3 V */
2121 const float conversionFactor = 3.3f / (1 << 12 );
2222
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 ;
2525
2626 if (unit == 'C' ) {
2727 return tempC ;
2828 } else if (unit == 'F' ) {
2929 return tempC * 9 / 5 + 32 ;
3030 }
3131
32- return -1.0 ;
32+ return -1.0f ;
3333}
3434
3535int main () {
3636 stdio_init_all ();
37+ #ifdef PICO_DEFAULT_LED_PIN
3738 gpio_init (PICO_DEFAULT_LED_PIN );
3839 gpio_set_dir (PICO_DEFAULT_LED_PIN , GPIO_OUT );
40+ #endif
3941
4042 /* Initialize hardware AD converter, enable onboard temperature sensor and
4143 * select its channel (do this once for efficiency, but beware that this
@@ -48,10 +50,12 @@ int main() {
4850 float temperature = read_onboard_temperature (TEMPERATURE_UNITS );
4951 printf ("Onboard temperature = %.02f %c\n" , temperature , TEMPERATURE_UNITS );
5052
53+ #ifdef PICO_DEFAULT_LED_PIN
5154 gpio_put (PICO_DEFAULT_LED_PIN , 1 );
5255 sleep_ms (10 );
5356
5457 gpio_put (PICO_DEFAULT_LED_PIN , 0 );
58+ #endif
5559 sleep_ms (990 );
5660 }
5761
You can’t perform that action at this time.
0 commit comments