Created
February 8, 2016 23:24
-
-
Save bennuttall/aae0ec488216033774ac to your computer and use it in GitHub Desktop.
Programming the onboard LEDs (activity and power lights) with GPIO Zero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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