################################################## from PyGlow import PyGlow from time import sleep pyglow = PyGlow() val = 100 color = 2 dark = 1 pyglow.all(0) while True: if color == 7: break pyglow.led(color, val) pyglow.led(dark, 0) sleep(0.5) color = color + 1 dark = dark + 1 while True: a = color b = a + 6 pyglow.led(a, val) pyglow.led(b, val) sleep(0.1) high = high + 1
#! /usr/bin/local/python3 from PyGlow import PyGlow from time import sleep import random pyglow = PyGlow() pyglow.all(0) while True: randomLED = random.randint(1,18) randomBright = random.randint(0,100) pyglow.led(randomLED,randomBright) sleep(0.1) pyglow.led(randomLED,0) pyglow.all(0)
################################################## ## Switch each colour on in sequence on and off ## ## ## ## Example by Jason - @Boeeerb ## ################################################## from PyGlow import PyGlow from time import sleep pyglow = PyGlow() val = 20 colour = 1 while True: if colour == 19: colour = 1 if val == 20: val = 0 else: val = 20 pyglow.led(colour, val) sleep(0.05) colour = colour + 1
else: while counter >= threshold: counter -= threshold BallX += BallXSpeed BallY += BallYSpeed if BallX == 0 or BallX == WIDTH - 1: p.ChangeFrequency(N_SCORE) p.start(50) Serving = True ServeCount = (ServeCount + 1) % 10 if BallX == 0: Player1Score += 1 else: Player0Score += 1 BallXSpeed = 1 if ServeCount < 5 else -1 for i in range(1, 19): glow.led(i, 255) sleep(.05) p.ChangeFrequency(N_SCORE+200) for i in range(18, 0, -1): glow.led(i, 0) sleep(.05) if BallX == 2 and 0 <= BallY - Player0Bat < Player0Height or BallX == WIDTH - 3 and 0 <= BallY - Player1Bat < Player1Height: N_BOUNCE = abs(N_BOUNCE - 1500) p.ChangeFrequency(N_BOUNCE) p.start(50) sfxStartTime = time() BallXSpeed = -BallXSpeed BallX += BallXSpeed if BallX == 3: BallYSpeed = 3 * (BallY - Player0Bat) / Player0Height - 1 else:
#PyGlow test from PyGlow import PyGlow from time import sleep pyglow = PyGlow() pyglow.all(0) pyglow.led(1,100) sleep(1) pyglow.led(1,0) sleep(1) pyglow.update_leds()
binmin = "%06d" % int(bin(min)[2:]) binsec = "%06d" % int(bin(sec)[2:]) # Check if current hour is different and set ready to flash hour if hourcurrent != hour: hourcount = hour hourcurrent = hour if armbottom == "h": arm3 = list(binhour) elif armbottom == "m": arm3 = list(binmin) else: arm3 = list(binsec) led13 = ledbrightness if arm3[5] == "1" else 0 pyglow.led(13, led13) led14 = ledbrightness if arm3[4] == "1" else 0 pyglow.led(14, led14) led15 = ledbrightness if arm3[3] == "1" else 0 pyglow.led(15, led15) led16 = ledbrightness if arm3[2] == "1" else 0 pyglow.led(16, led16) led17 = ledbrightness if arm3[1] == "1" else 0 pyglow.led(17, led17) led18 = ledbrightness if arm3[0] == "1" else 0 pyglow.led(18, led18) if armright == "h": arm2 = list(binhour) elif armright == "m": arm2 = list(binmin)
from PyGlow import PyGlow from time import sleep pyglow = PyGlow() pyglow.all(0) pyglow.led(1, 100) sleep(1) pyglow.led(1, 0) sleep(1) pyglow.update_leds()
ball_motion[1] = random.choice([-1, -1, 0, 1, 1]) # Start the match match() audio.tone2(0.4) # Reset the serve buttons serve[0] = False serve[1] = False # Re-draw the scores print_score() # PyGlow effects for point scored for i in range(1, 7): pyglow.led([i, i + 6, i + 12], 255) time.sleep(0.25) for i in range(6, 0, -1): pyglow.led([i, i + 6, i + 12], 0) time.sleep(0.25) pyglow.all(0) # Change serving player if current one has no serves left if serves[player_serve] == 0: serves[player_serve] = 5 if player_serve == 0: player_serve = 1 else: player_serve = 0 output(ANSIEscape.clear_screen())
from PyGlow import PyGlow from time import sleep pyglow = PyGlow() pyglow.all(0) count = 0 while (count < 20): pyglow.led(1, 100) pyglow.led(8, 100) pyglow.led(15,100) pyglow.led(4, 100) pyglow.led(11,110) pyglow.led(18,40) sleep(0.1) pyglow.led(1, 0) pyglow.led(8, 0) pyglow.led(15,0) pyglow.led(4, 0) pyglow.led(11,0) pyglow.led(18,0) pyglow.led(13,100) pyglow.led(2, 100) pyglow.led(9, 100) pyglow.led(16,100) pyglow.led(5, 110) pyglow.led(12,40) sleep(0.1) pyglow.led(13,0)
# PyGlow # ##### # # Python module to control Pimoronis PiGlow # [http://shop.pimoroni.com/products/piglow] # # * pulsetest.py - test the pulsing light feature # ##### from PyGlow import PyGlow b = input("Maximum brightness: ") s = input("Speed in milliseconds (try 1000 as a default): ") pyglow = PyGlow(brightness=int(b), speed=int(s), pulse=True) pyglow.all(0) print("Pulsing 1 Light") pyglow.led(1) print("Pulsing Arms") pyglow.arm(1) pyglow.arm(2) pyglow.arm(3) print("Pulsing All") pyglow.all()
##### # # Python module to control Pimoronis PiGlow # [http://shop.pimoroni.com/products/piglow] # # * pulsetest.py - test the pulsing light feature # ##### from PyGlow import PyGlow b = input("Maximum brightness: ") s = input("Speed in milliseconds (try 1000 as a default): ") pyglow = PyGlow(brightness=b, speed=s, pulse=True) pyglow.all(0) print("Pulsing 1 Light") pyglow.led(1) print("Pulsing Arms") pyglow.arm(1) pyglow.arm(2) pyglow.arm(3) print("Pulsing All") pyglow.all()
from PyGlow import PyGlow from time import sleep pyglow = PyGlow() pyglow.all(0) count = 0 while (count < 10): pyglow.led(1, 100) pyglow.led(7, 100) pyglow.led(13,100) sleep(0.1) pyglow.led(1, 0) pyglow.led(7, 0) pyglow.led(13,0) pyglow.led(2, 100) pyglow.led(8, 100) pyglow.led(14,100) sleep(0.1) pyglow.led(2, 0) pyglow.led(8, 0) pyglow.led(14,0) pyglow.led(3, 100) pyglow.led(9, 100) pyglow.led(15,100) sleep(0.1) pyglow.led(3, 0) pyglow.led(9, 0)