コード例 #1
0
run with: python3 tutorial2.py
================================================

This example uses the write_pin and writePort methods to switch pin 1 on
and off on the IO Pi.
"""
from ABE_helpers import ABEHelpers
from ABE_IoPi import IoPi
import time

i2c_helper = ABEHelpers()
i2c_bus = i2c_helper.get_smbus()

bus = IoPi(i2c_bus, 0x20)

bus.set_pin_direction(1, 1)  # set pin 1 as an input

bus.set_pin_direction(8, 0)  # set pin 8 as an output

bus.write_pin(8, 0)  # turn off pin 8

bus.set_pin_pullup(1, 1)  # enable the internal pull-up resistor on pin 1

bus.invert_pin(1, 1)  # invert pin 1 so a button press will register as 1

while True:

    if bus.read_pin(1) == 1:  # check to see if the button is pressed
        print('button pressed')  # print a message to the screen
        bus.write_pin(8, 1)  # turn on the led on pin 8
        time.sleep(2)  # wait 2 seconds
コード例 #2
0
    CounterPinValue = {}
    PinNextSend = {}
    TempoPinHIGH = {}
    TempoPinLOW = {}
    Status_pins = {}
    Status_INPUTS = {}
    swtch = {}
    exit = 0
    SetAllLOW = 0
    SetAllHIGH = 0
    SetAllSWITCH = 0
    SetAllPulseLOW = 0
    SetAllPulseHIGH = 0
    pinStr = ''
    for i in range(0, 16):
        bus.set_pin_direction(i + 1, 1)
        input = bus.read_pin(i + 1)
        Status_INPUTS[i] = input
        pinStr += '&IN_' + str(i) + '=' + str(input)
        CounterPinValue[i] = 0
        PinNextSend[i] = 0
        TempoPinHIGH[i] = 0
        TempoPinLOW[i] = 0
        swtch[i] = 0
        Status_pins[i] = '.'

    # Envoi de l'etats des inputs au boot
    if pinStr != '':
        SimpleSend(pinStr)

    threadLock = threading.Lock()
コード例 #3
0
run with: sudo python tutorial1.py
================================================

This example uses the write_pin and writePort methods to switch pin 1 on
and off on the IO Pi.
"""
from ABE_helpers import ABEHelpers
from ABE_IoPi import IoPi
import time

i2c_helper = ABEHelpers()
i2c_bus = i2c_helper.get_smbus()

bus = IoPi(i2c_bus, 0x20)

bus.set_pin_direction(1, 1)  # set pin 1 as an input

bus.set_pin_direction(8, 0)  # set pin 8 as an output

bus.write_pin(8, 0)  # turn off pin 8

bus.set_pin_pullup(1, 1)  # enable the internal pull-up resistor on pin 1

bus.invert_pin(1, 1)  # invert pin 1 so a button press will register as 1


while True:

    if bus.read_pin(1) == 1:  # check to see if the button is pressed
        print 'button pressed'  # print a message to the screen
        bus.write_pin(8, 1)  # turn on the led on pin 8