• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Learn PAsPi Pico book page 157

Q&A Forum › Category: Raspberry Pi › Learn PAsPi Pico book page 157
0 Vote Up Vote Down
Rudolf Reiber asked 1 year ago

Why needs the

def toggle_green_led(timer) and def toggle_blue_led(timer)
the "timer" in parathesis? Such a variable is nowhere declared.
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

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

0 Vote Up Vote Down
Rudolf Reiber answered 1 year ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
Thanks for pointing that out.
I’ll test the code and fix that.
Regards,
Sara

0 Vote Up Vote Down
Rudolf Reiber answered 1 year ago

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


0 Vote Up Vote Down
Rudolf Reiber answered 1 year ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Thanks.
That was word converting the starting of a sentence automatically to cap words.
Always copy the code from the Github link and not from the PDF.
I’ll fix that. Thanks.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.