Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Created February 8, 2016 23:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bennuttall/aae0ec488216033774ac to your computer and use it in GitHub Desktop.
Save bennuttall/aae0ec488216033774ac to your computer and use it in GitHub Desktop.
Programming the onboard LEDs (activity and power lights) with GPIO Zero
from gpiozero import LED
from time import sleep
from signal import pause
red = LED(35)
green = LED(47)
def blink(n):
red.blink(n, n)
sleep(n)
green.blink(n)
blink()
pause()
from gpiozero import PWMLED
from time import sleep
red = PWMLED(35)
green = PWMLED(47)
def opp():
while True:
yield 1 - red.value
green.source = opp()
while True:
for i in range(11):
red.value = i / 10
sleep(0.05)
for i in reversed(range(11)):
red.value = i / 10
sleep(0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment