User Tools

Site Tools


led_on_and_off

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
led_on_and_off [2026/06/12 22:31] – [Introduction] walkeradminled_on_and_off [2026/06/17 16:39] (current) walkeradmin
Line 10: Line 10:
 \\  \\ 
 \\  \\ 
-{{ :raspberry-pi-pico_-_led.png?300 |}}+{{ :raspberry-pi-pico_-_led.png?200 |}}
 \\  \\ 
 In the above picture we can see where the LED is. Once powered on the LED by default will be off, and we will need to use some micro python to turn it on. In the above picture we can see where the LED is. Once powered on the LED by default will be off, and we will need to use some micro python to turn it on.
Line 18: Line 18:
 \\  \\ 
 \\  \\ 
-{{ :thonny-led-on.png?800 |}}+{{ :thonny-led-on.png?650 |}}
 \\  \\ 
 Here we can see the code that we need to enter in to Thonny. Here we can see the code that we need to enter in to Thonny.
 \\  \\ 
 \\  \\ 
-<code | download>+<code:python | download>
 # Import the picozero LED class # Import the picozero LED class
 from picozero import pico_led from picozero import pico_led
Line 30: Line 30:
 pico_led.on() pico_led.on()
 </code> </code>
 +\\  
 +To run this code, click the green play button on the Thonny toolbar. This of course turns the Pi Pico LED on. 
 +\\  
 +\\  
 +{{ :pico_led_on.png?400 |}} 
 +\\ 
 This code does a couple of things: This code does a couple of things:
 \\  \\ 
Line 36: Line 41:
 **from picozero import pico_led** **from picozero import pico_led**
 \\  \\ 
 +    This line imports the pico_led object from the picozero library.
 +    
 +    picozero is a beginner‑friendly library for controlling hardware on the Raspberry Pi Pico.
 +    
 +    pico_led is a built‑in object that represents the on‑board LED (the little LED already on the Pico board).
 +    
 +    So this line is basically saying: “Give me access to the Pico’s built‑in LED so I can control it.”
 \\  \\ 
-This line imports the pico_led object from the picozero library.+**pico_led.on()**
 \\  \\ 
-picozero is a beginner‑friendly library for controlling hardware on the Raspberry Pi Pico.+ 
 +    This is the line that actually turns the LED on. 
 +     
 +    pico_led is the LED object 
 +     
 +    .on() is a function that switches it on 
 +     
 +    The LED lights up and stays on until you turn it off or reset the board 
 +     
 +    It’s the simplest possible way to control hardware on the Pico.
 \\  \\ 
-pico_led is a built‑in object that represents the on‑board LED (the little LED already on the Pico board).+Now that you have turned the LED on, you might want to turn it off, and the program is almost the same except for the argument for the pico_led line.
 \\  \\ 
-So this line is basically saying:+<code:python | download> 
 +# Import the picozero LED class 
 +from picozero import pico_led 
 + 
 +#Turn on the pico LED 
 +pico_led.off() 
 +</code> 
 +As you can see in the code above, all we have done is to change the pico_led.<color #ed1c24>on</color>() to pico_led.<color #ed1c24>off</color>()
 \\  \\ 
-“Give me access to the Pico’s built‑in LED so I can control it.+\\  
 +This now turns of the Pi Pico LED
 +\\  
 +\\  
 +{{ :pico_led_off.png?400 |}} 
 +\\  
 +That is it, we can now successfully turn on and off the onboard LED on the Pi Pico, as well as creating our first piece of Micro Python in Thonny. 
 +\\  
 +\\  
 +---- 
led_on_and_off.1781303494.txt.gz · Last modified: by walkeradmin