Here, we see the LED class at line (4) in the following is created and assigned to the led variable. The parameter to LED is the GPIO pin that the physical LED is connected to, as per the breadboard in Figure 2.1:
GPIO_PIN = 21
led = LED(GPIO_PIN) # (4)
led.blink(background=False) # (5)
On line (5), we start the LED blinking. The background=False parameter to blink() is needed to run the LED on the main thread so the program does not exit (an alternative of background=True would be to use signal.pause(). We'll see an example of this in the next section).
GPIOZero makes it very easy to interface with common electronic components such as an LED. Next, we will perform the same exercise, only this time using the PiGPIO library.