Blink The Onboard LED
Our first program will just blink the on-board LED on the Raspberry Pi Pico.
It is a great way to tell if you got Thonny installed correctly
and that your computer can connect to the Raspberry Pi Pico.
Use the "copy" icon in the upper right corner to copy the code
below into your pastebuffer. Then open Thonny and paste it into
a new file in your Thonny editor (or other Python programming tool).
Then press the "Run" button. You should see the small green
LED on the Pico flashing on and off every second.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
When you run this program, the built-in LED on the Pico will blink every second.
Challenges
- Change the delay time to be
0.25
seconds on and0.25
second off. - How fast can you make the LED blink?
- Go to the original MicroPython for Kids website and search for the term "blink" in the search form in the upper right. What variations of blink are there in other kits?
- If you have any LEDs and 330 ohm resistors, try adding them to the breadboard and getting the external LED to blink. See this lab for sample code.
Debugging Tips.
If you are not getting any response when you click the "Run" button, try checking that your desktop computer is communicating with the Raspberry Pi Pico through the USB cable.
See the Setup Desktop Debugging Tips page for tips on how to make sure your connection is working.