5101+ reviews
Order by 16:00 for same day shipping
14 days return
GB
EN
Individual
Business
In this project you will learn how to blink an LED using the GPIO pins of the Raspberry Pi. For this project we use Python and the Thonny IDE, which is available by default in the Raspberry Pi OS.
from gpiozero import LED
from time import sleep
# LED aangesloten op GPIO 17
led = LED(17)
# Start een oneindige loop
while True:
led.on() # Zet LED aan
sleep(1) # Wacht 1 seconde
led.off() # Zet LED uit
sleep(1) # Wacht 1 seconde
3. Save the file: Click File > Save As and name the file led_blink.py.
4. Run the script: Click on the greenRun button (▶) at the top of the Thonny interface
If everything is connected correctly and the script has been executed correctly, the LED will be on for one second, then off for one second, and repeat this pattern.
led2 = LED(27) # Nieuwe LED op GPIO 27
With this adjustment, the program is easy to use and will only stop when you indicate so. Have fun with your flashing LED!