We will jump right into the code:
- Create a new file in Thonny, and call it Hello LED.py or something similar.
- Type in the following code and run it:
from gpiozero import LED
led = LED(18)
led.blink(1,1,10)
We will jump right into the code:
from gpiozero import LED
led = LED(18)
led.blink(1,1,10)
If we wired up our circuit and typed in our code correctly, we should see our LED blink for 10 seconds in 1 second intervals. The blink function in the gpiozero LED object allows us to set on_time (the length of time in seconds that the LED stays on), off_time (the length of time in seconds that the LED is turned off for), n or the number of times the LED blinks, and background (set to True to allow other code to run while the LED is flashing).
The blink function call with its default parameters...