This is an old revision of the document!
Blink the LED
Introduction
We have already looked at how to flash the LED on the Pi Pico using Micro Python. So why are we talking about 'Blinking' and LED as opposed to flashing the LED?
The build in pico_led function has a 'blink' command, and this makes blinking the LED really simple from a code perspective.
Look at the following Micro Python code:
- download
from picozero import pico_led pico_led.blink(0.5)
If you copy/paste this in to Thonny and run it, you will see that just like our flashing LED example, the LED flashed twice a second.
So, why would we use the flashing version, that has multiple lines of code over using the 2 lines of code blinking version?? Well the answer is quite simple:
- 1. If you use the blinking version, the code is simple.
- 2. If you use the flashing version, the code is slightly more complex but you get control over the duty cycle, that is you can have the led on longer than it is off, or visa-versa.
There might be other reasons, I just have not thought about them :)

