#!/usr/bin/env python

"""Make an LED pulsate by fading in/out, varying the duty cycle.
"""

from blinkenlights import dimmer, setup, cleanup

pin = 18
bpm = 50

setup(pin)

up = range(10)
down = range(9)
down.reverse()
spectrum = up + down + [-1]

period = 60.0 / bpm  # period is in seconds
time_per_level = period / len(spectrum)
# if time_per_level > 0.08 then the levels look too jerky.

for i in range(10):  # 10 beats
    for j in spectrum:
        brightness = (j + 1) / 10.0
        dimmer(brightness, time_per_level, pin)

cleanup()
示例#2
0
in column 1. The ball is any of the four LEDs in columns 2-3. Player 2
can move up and down in column 4.

.  b  .  p2
p1 .  .  .
"""

from blinkenlights import setup, cleanup
from fourleds import light, clear
from time import sleep
import random

pins = [37, 33, 31, 29, 36, 32, 22, 18]
#       yp  ym  gp  gm  rp  rm  bp  bm

setup(pins)

### Test pattern

clear(pins)
for i in pins:
    light(i)
    sleep(0.1)
    clear(pins)

#### Definitions

class Ball:
    def __init__(self, LL, UL, LR, UR):
        self.field = [[LL, UL], [LR, UR]]
        self.field_pins = [LL, UL, LR, UR]
示例#3
0
#!/usr/bin/env python

"""Count upwards in binary using four LEDs."""

from blinkenlights import setup, cleanup
from fourleds import encode, light, clear
from time import sleep

all_leds = [32, 22, 18, 16]
#           blu grn red yel

for p in all_leds:
    setup(p)

for i in range(31):
    encode(i, all_leds)
    sleep(1)

cleanup()