GPIO Programming

#!/usr/bin/env python
#
# BUTTON     PWMLED
# ------     ------
# pressed    on
# released   off
# held       pulse
#

from gpiozero import Button, PWMLED  
from signal import pause

btn = Button(20)  
led = PWMLED(21)

btn.when_pressed = led.on  
btn.when_released = led.off  
btn.when_held = led.pulse

pause()