Пример #1
4
from gpiozero import LEDBoard
from time import sleep
from signal import pause

leds = LEDBoard(5, 6, 13, 19, 26)

leds.on()
sleep(1)
leds.off()
sleep(1)
leds.value = (1, 0, 1, 0, 1)
sleep(1)
leds.blink()

pause()
Пример #2
0
def active_seismometer(callback, callback_interval):
    buzzer = Buzzer(3)
    status_led = LED(26)
    scale_led = LEDBoard(a=18, b=23, c=12, d=19, e=6, f=22, g=17, xdp=16)

    seismometer = Seismometer()
    seismometer.start_calculation(callback, callback_interval)

    while True:
        try:
            seismic_scale = seismometer.seismic_scale
            scale_led.value = SCALE_LED_CHARSETS[
                seismometer.get_user_friendly_formatted_seismic_scale()]

            if seismometer.ready:
                if not status_led.is_lit:
                    status_led.on()

                if seismic_scale >= 3.5:
                    if not buzzer.is_active:
                        buzzer.on()
                else:
                    buzzer.off()
        except KeyboardInterrupt:
            break

    seismometer.stop_calculation()
    scale_led.off()
    status_led.off()
    buzzer.off()
#!/usr/bin/python3
from gpiozero import LEDBoard
from signal import pause

leds = LEDBoard(21, 20, 16, 12, 7, 8, 25, 23, pwm=True)

print("Press Crtl-C to stop the program.")
while True:
    try:
        leds.value = (0.2, 0.3, 0.4, 0.5, 0.6, 1, 0.7, 0.8)
        pause()
    except KeyboardInterrupt:
        print("Stopping program.\n")
        leds.close()
        exit()
Пример #4
0
from gpiozero import LEDBoard
from time import sleep
from signal import pause

leds = LEDBoard(21, 20, 26, 16, 19, 13, 12, 6, 5, 1, 0, 7, 8, 11, 25, 9, 10,
                24, 23, 22, 27, 18, 17, 15, 14, 4, 3, 2)

leds.on()
sleep(1)
leds.off()
sleep(1)

sleepTime = 0.075
lightArray = [
    1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0
]

while True:
    leds.value = tuple(lightArray)
    lastVal = lightArray.pop()
    lightArray.insert(0, lastVal)
    sleep(sleepTime)

pause()
Пример #5
0
#!/usr/bin/env python3

from gpiozero import Button
from gpiozero import LEDBoard
import time

#btn = Button( 26, pull_up = True, bounce_time= None)
btn = Button(26, pull_up=True, bounce_time=0.1)
leds = LEDBoard(13, 19)
leds.value = (1, 1)

print("ANAVI Smiley")
print("---")
print("Please press the button")
print("---")

counter = 1

while True:
    time.sleep(0.2)
    if btn.is_pressed:
        print("Button pressed, sequence: ", counter)
        if 0 == counter:
            leds.value = (1, 1)
        if 1 == counter:
            leds.value = (1, 0)
        if 2 == counter:
            leds.value = (0, 1)
        if 3 == counter:
            leds.value = (0, 0)
        counter += 1
Пример #6
0
from gpiozero import LEDBoard
from time import sleep

leds = LEDBoard(23, 24, 25, 4)
bincounter = 1
while bincounter <= 15:
    myTempString = "000" + str(bin(bincounter))[2:]
    leds.value = (int(myTempString[-4]), int(myTempString[-3]),
                  int(myTempString[-2]), int(myTempString[-1]))
    sleep(1)
    bincounter += 1
Пример #7
0
#!/usr/bin/python3
# coding: utf-8
from gpiozero import LEDBoard
from time import sleep

leds = LEDBoard(18, 23, 24, 25, 8, 16, pwm=True)

while 1:
    leds.on()
    #sleep(2)
    #leds.off()
    #sleep(2)
    leds.value = (1, 1, 1, 1, 1)
    sleep(2)
    #leds.value = (0.2, 0.4, 0.6, 0.8, 1.0)
    #sleep(2)
    leds.blink()
    sleep(10)
pass
Пример #8
0
#!/usr/bin/python3

from gpiozero import LEDBoard
from signal import pause

leds = LEDBoard(4, 17, 22, pwm=True)

leds.value = (0.1, 0.2, 1.0)

pause()
Пример #9
0
print('=================================================')
print('|                   LEDBoard                    |')
print('|  -------------------------------------------  |')
print('|            Use 220 ohm resistors              |')
print('|         Connect LED cathode to GND            |')
print('|         Uses pulse-width modulation           |')
print('|        Click Ctrl + C to exit program         |')
print('|------------------------------------------------')
print('|                                   PythonCoder8|')
print('=================================================')

try:
    leds = LEDBoard(5, 6, 13, pwm=True)
    while True:
        leds.value = (1, 1, 1)
        sleep(0.03)

        leds.value = (0.9, 0.9, 0.9)
        sleep(0.03)

        leds.value = (0.8, 0.8, 0.8)
        sleep(0.03)

        leds.value = (0.7, 0.7, 0.7)
        sleep(0.03)

        leds.value = (0.6, 0.6, 0.6)
        sleep(0.03)

        leds.value = (0.5, 0.5, 0.5)
Пример #10
0
# GPIOZERO_PIN_FACTORY=pigpio PIGPIO_ADDR=192.168.4.158

from gpiozero import LEDBoard
from time import sleep
from signal import pause
from gpiozero.pins.pigpio import PiGPIOFactory

pi_host = '192.168.4.158'
factory = PiGPIOFactory(host=pi_host)

leds = LEDBoard(6, 5, 22, 27, 17, pin_factory=factory, pwm=True)

led_value = (0.1, 0.3, 0.5, 0.7, 0.9)

leds.value = led_value

sleep(1)

leds.off()
Пример #11
0
from gpiozero import LEDBoard
from time import sleep


leds = LEDBoard(17, 3, pwm=True)

while True:
    leds.on()
    sleep(1)
    leds.off()
    sleep(1)
    leds.value = (0.8, 0.2)
    sleep(1)
    leds.value = (0.5, 0.9)
    sleep(1)

Пример #12
0
from gpiozero import LEDBoard
from time import sleep
from signal import pause
from gpiozero import PWMLED

# Create my LEDs

leds = LEDBoard(5, 6, 13, 19, 26)
#leds = LEDBoard(5, 6, 13, 19, 26, pwm=True)
leds2 = PWMLED(5)  # Have to create each led individually to be used with pulse
leds.on()
sleep(1)
leds.off()
sleep(1)
leds.value(1, 0, 1, 0, 1)
sleep(1)
leds.blink()
sleep(3)
leds2.pulse(2, 1, 1, False)
Пример #13
0
# Starter code taken from https://learn.adafruit.com/adafruit-mpr121-12-key-capacitive-touch-sensor-breakout-tutorial/python-circuitpython

import time
import board
import busio
# Import MPR121 module.
import adafruit_mpr121

from gpiozero import LED, LEDBoard

# Create I2C bus.
i2c = busio.I2C(board.SCL, board.SDA)

# Create MPR121 class.
mpr121 = adafruit_mpr121.MPR121(i2c)

# we will output touches on GPIO Pins of the Pi
TOUCH_LEFT = 12
TOUCH_DOWN = 16
TOUCH_UP = 20
TOUCH_RIGHT = 21

touchOut = LEDBoard(TOUCH_LEFT, TOUCH_DOWN, TOUCH_UP, TOUCH_RIGHT)

# Loop forever testing each input and printing when they're touched.
while True:
    print(mpr121[0].value, mpr121[2].value, mpr121[4].value, mpr121[6].value)
    touchOut.value = (mpr121[0].value, mpr121[2].value, mpr121[4].value,
                      mpr121[6].value)
Пример #14
0
                    leadMin = leadMin + 1
                else:
                    trailMin = trailMin + 1

        # if not at 11pm, carry this out
        # increment hour by 1 if at 59 minutes
        else:
            if leadMin == 5 and trailMin == 9:
                leadMin, trailMin = 0, 0
                # determine whether to increment leading hour or not
                if trailHour == 9:
                    trailHour = 0
                    leadHour = leadHour + 1
                else:
                    trailHour = trailHour + 1

            # increment minute by 1 if not at 59
            # determine whether to increment leading Minute or not
            else:
                if trailMin == 9:
                    trailMin = 0
                    leadMin = leadMin + 1
                else:
                    trailMin = trailMin + 1
    else:
        AN.value = (0, 0)
        tubesOn.off()
        break

call("sudo shutdown -h now", shell=True)
Пример #15
0
from gpiozero import LEDBoard
from signal import pause

leds = LEDBoard(5, 6, 13, 19, 26, pwm=True)

leds.value = (0.2, 0.4, 0.6, 0.8, 1.0)

pause()
Пример #16
0
from gpiozero import LEDBoard
from signal import pause

leds = LEDBoard(18, 23, 24, pwm=True)

leds.value = (0.2, 0.4, 0.6)

pause()
Пример #17
0
from gpiozero import LEDBoard
from time import sleep
from signal import pause

leds = LEDBoard(18, 23, 24)

# 모두 같이 동작
leds.on()
sleep(1)
leds.off()
sleep(1)

# 개별적인 값을 튜플로 지정
leds.value = (1, 0, 1)
sleep(1)
leds.blink()
pause()
Пример #18
0
from gpiozero import LEDBoard

leds = LEDBoard(5, 6, 13, 19, 26, pwm=True)

leds.value = (0.2, 0.4, 0.6, 0.8, 1.0)