Why needs the
def toggle_green_led(timer) and def toggle_blue_led(timer)
the "timer" in parathesis? Such a variable is nowhere declared.
Hi.
I’m sorry. I should have explained that in the eBook.
The callback functions for the timer event must take one argument. The Timer object is passed automatically as an argument to that function when the event is triggered.
You must have that argument even though you don’t use it.
For more info you can check the documentation: https://docs.micropython.org/en/latest/library/machine.Timer.html#methods
I’ll add that information to the next eBook update.
Thanks.
Regards,
Sara
Hi Sara, thank you for your quick answer.
I fond a bug in the code of “Getting Temperature from Multiple Sensors (with Address)” Page 195/196
After the while true statement, there are the two lines
ds_sensor.convert_temp()
time.sleep_ms(750)
missing. Without them the second sensor says, that in my room it a temperatur of 80 °C, a litte to much.
Sencerely yours, Rudolf from Germany
Hi.
Thanks for pointing that out.
I’ll test the code and fix that.
Regards,
Sara
Good morning Sara,
there is a typo on page 138:
from picozero import pico_temp_sensor
# Convert from celsius to fahrenheit
def celsius_to_fahrenheit(temp_celsius): temp_fahrenheit = temp_celsius * (9/5) + 32 return temp_fahrenheit
# Reading and printing the internal temperature
Temperature_c = pico_temp_sensor.temp Temperature_f = celsius_to_fahrenheit(temperature_c)
print("Internal Temperature:", temperature_c, "°C") print("Internal Temperature:", temperature_f, "°F")
You defined the temperature with an T but in the print statement the temperature is with a t.
Sencerely Yours,
Rudolf from Germany
Hi Sara, I found a typo on page 203: a ‘d’ too much.
The best and easiest way to find out is to run and I2C scanner. This is a …
Regardes, Rudolf