012 – Raspberry Pi Pico 2W Internal LED and Internal Temperature Sensor

Raspberry Pi Pico 2W - Internal Temperature Sensor and Internal LED

Raspberry Pi Pico and Pico 2 Built In Temperature Sensor and Built In LED

The Raspberry Pi Pico 2W has a small light-emitting diode (LED) built into the board. You can turn it on, off, or make it blink using simple code, which is useful for testing or showing when something is happening. It also has a built-in temperature sensor that can read the board’s own temperature without adding any extra parts. These two features make it easy to start learning and creating projects.

Video Instructions: Controlling the Raspberry Pi Pico 2W’s Internal LED with the Internal Temperature Sensor

Raspberry Pi Pico 2W Temperature Sensor and Internal LED Code

This code makes the Raspberry Pi Pico 2W read its own temperature and turn the built-in LED on or off depending on how warm it is.

It starts by setting up the LED so it can be controlled, and the temperature sensor so it can read the temperature.

The while True: loop makes the code run forever.

It reads the temperature sensor, changes the reading into degrees Celsius, and shows the temperature on the screen.

If the temperature is above 26°C, it turns the LED on.

If the temperature is below 26°C, it turns the LED off.

It pauses for half a second between each reading.

This means the Pico 2W is always checking its own temperature and using the LED as a simple indicator.

Internal Temperature Sensor and internal LED

Leave a Comment

Your email address will not be published. Required fields are marked *