コード例 #1
0
def main():
    """ メイン関数 """
    # 接続ピン
    PIN_LD = 23
    # A/D変換チャネル数
    NUM_CH = 4

    # 赤色LED設定(PWM)
    red = PWMLED(PIN_LD)
    # フォトリフレクタ(複数)設定(A/D変換)
    photorefs = [MCP3004(channel=idx) for idx in range(NUM_CH)]

    # 計測データ平均をLED入力に接続
    red.source = averaged(photorefs[0], photorefs[1], photorefs[2],
                          photorefs[3])

    # 停止(Ctrl+c)まで待機
    pause()
コード例 #2
0
from gpiozero import PWMLED
from gpiozero.tools import ramping_values
from signal import pause

red = PWMLED(2)

red.source_delay = 0.01
red.source = ramping_values(100)

pause()

    step = 2 / 1
    value = 0
    while True:
        yield value
        value += step
        if isclose(value, 1, abs_tol=1e-9):
            value = 1
            step *= -1
        elif isclose(value, 0, abs_tol=1e-9):
            value = 0
            step *= -1
        elif value > 1 or value < 0:
            step *= -1
            value += step
コード例 #3
0
from gpiozero import LightSensor, PWMLED
from signal import pause

sensor = LightSensor(18)
led = PWMLED(17)

led.source = sensor

pause()

コード例 #4
0
##Convert data to Alien Language
def text_man(your_data_string):
    return iota.TryteString.from_unicode(your_data_string)


##The end of my Magic Book...

My_new_fkin_wallet = create_one_miniwallet()
var = 1
led1 = PWMLED(5)
led2 = PWMLED(6)
led3 = PWMLED(13)
led4 = PWMLED(19)
led5 = PWMLED(26)
while var == 1:
    pot = MCP3008(0)
    print(pot.value * 10)
    time.sleep(10)
    print("Reading:")
    ##tatara = ascii(pot.values)
    ##tatara=str(float(tatara))
    led1.source = pot.values
    led2.source = pot.values
    led3.source = pot.values
    led4.source = pot.values
    led5.source = pot.values
    a_piece_of_spam = text_man("SPAM")
    data_transfer(a_piece_of_spam, My_new_fkin_wallet[2],
                  My_new_fkin_wallet[0])
コード例 #5
0
from gpiozero import PWMLED, MCP3008
from signal import pause

led = PWMLED(17)
pot = MCP3008()

led.source = pot.values

pause()
コード例 #6
0
from subprocess import check_call
from gpiozero.tools import random_values
from random import *
import time

# set up various delay values
delay = 0.05  #used in spiral function
delay2 = 0.03  #used in spiral function
on_delay = 0.01  #used in random_led function
top_down_delay = 0.125  # used in top_down function
top_down_delay2 = 0.05  # used in top_down function
sides_delay = 0.075  # used in the sides function

# Just flicker the star led
star = PWMLED(2)
star.source = random_values()


# define the shutdown sequence for the shutdown button
def shutdown():
    check_call(['sudo', 'poweroff'])


shutdown_btn = Button(3)

period_min = 3  # base number of seconds for each function
period_max = 10  # maximum number of seconds for each function


def spiral():
    # function to create a spiral pattern that repeats for a while
コード例 #7
0
ファイル: button.py プロジェクト: Kasamens/GPIO
from gpiozero import PWMLED, Button
from signal import pause


red_led = PWMLED(17)
button = Button(2)

red_led.source = button.values

pause()
コード例 #8
0
ファイル: light_sensor_3.py プロジェクト: VHSVictor/GPIOZERO
from gpiozero import LightSensor, PWMLED
from signal import pause

sensor = LightSensor(18)
led = PWMLED(16)

led.source = sensor.values

pause()
コード例 #9
0
# GPIO pints are digital, so you can only set outputs to high or low, or read inputs as high or low
# using an ADC chip (Analogue-to-Digital converter) you can read the value of analogue input devices like potentiometers

# analogue values are communicated to the Pi using the SPI protocol

# open a terminal window and install spidev package

### sudo apt-get install python3-spidev python-spidev

### open Raspberry Pi Configuration from main menu and enable "SPI" in the Interfaces tab

from gpiozero import MCP3008

pot = MCP3008(0)

# print(pot.value) # try to read potentiometer's value

### next, add an LED to your breadboard and wire it to the Pi, connecting it to GPIO pin 21

from gpiozero import PWMLED  # lets you control the brightness of an LED using PWM (pulse-width modulation)

led = PWMLED(21)

led.source = pot.values  # turn the dial to change the LED brightness!
コード例 #10
0
ファイル: random_values.py プロジェクト: VHSVictor/GPIOZERO
from gpiozero import PWMLED
from gpiozero.tools import random_values
from signal import pause

led = PWMLED(4)
led.source = random_values()
led.source_delay = 0.1

pause()
コード例 #11
0
from gpiozero import PWMLED
from signal import pause
from connect import open_worksheet, read_cell_continuous

wks = open_worksheet("GPIO Zero")

led = PWMLED(2)

led.source = read_cell_continuous(wks, 1, 1)

pause()