Example #1
0
def tone(pin, frequency, duration=None):
    p = GPIO.PWM(pin, frequency)
    p.start(50)
    if duration is not None and duration > 0:
        threading.Timer(duration, lambda *args, **kwargs: p.stop()).start()
Example #2
0
def noTone(pin):
    GPIO.PWM(pin).stop()
Example #3
0
def digitalWrite(pin, value):
    try:
        GPIO.output(pin, value)
    except NameError:
        raise NameError(('Pin {} is not setup yet, please run'
                         '`pinMode({}, state)` first!').format(pin, pin))
Example #4
0
def digitalRead(pin):
    try:
        return GPIO.input(pin)
    except NameError:
        raise NameError(('Pin {} is not setup yet, please run'
                         '`pinMode({}, state)` first!').format(pin, pin))
Example #5
0
def noInterrupts():
    GPIO.disable_interrupts()
Example #6
0
def interrupts():
    GPIO.enable_interrupts()
Example #7
0
def detachInterrupt(pin):
    GPIO.remove_event_detect(pin)
Example #8
0
def pinMode(pin, state):
    GPIO.setup(pin, state)
Example #9
0
def attachInterrupt(pin, ISR, mode):
    GPIO.add_event_detect(pin, edge=mode, callback=[ISR])