예제 #1
0
def buttons_daemon (thread_name, delay):
	gpio = GPIO(debug=False)
	pinButtons = [2,3,4]
	state = [0,0,0]
	k = PyKeyboard()
	for i in pinButtons:
		gpio.pinMode(i, gpio.INPUT) 
	while True:
		for i in xrange(3):
			state[i] = gpio.digitalRead(pinButtons[i])
		if state[1] == 1 and state[2] == 0 and state[3] == 0: #Up Arrow
			k.tap_key('up')	
		if state[2] == 1 and state[1] == 0 and state[3] == 0: #Down Arrow (tab)
			k.tap_key('tab')
		if state[3] == 1 and state[1] == 0 and state[2] == 0: #OK (enter)
			k.tap_key('enter')
		#if state[]
		time.sleep(delay)
예제 #2
0
#!/usr/bin/python
# https://github.com/SavinaRoja/PyUserInput
import time
from wiringx86 import GPIOEdison as GPIO
gpio = GPIO(debug=False)
pinButtons = [2,3,4]
state = [0,0,0]
for i in pinButtons:
	gpio.pinMode(i, gpio.INPUT)
while True:
	for i in range(3):
		state[i] = gpio.digitalRead(pinButtons[i])
		if state[i] == 1:
                        print "Boton en pin " + str(pinButtons[i]) + " pulsado."
			time.sleep(3)
예제 #3
0
pin = 13
button = 2

print 'Setting up pins %d and %d...' % (pin, button)

# Set pin 13 to be used as an output GPIO pin.
gpio.pinMode(pin, gpio.OUTPUT)

# Set pin 2 to be used as an input GPIO pin.
gpio.pinMode(button, gpio.INPUT)

print 'Reading from pin %d now...' % button
try:
    while (True):
        # Read the state of the button
        state = gpio.digitalRead(button)

        # If the button is pressed turn ON pin 13
        if state == 1:
            gpio.digitalWrite(pin, gpio.HIGH)

        # If the button is not pressed turn OFF pin 13
        else:
            gpio.digitalWrite(pin, gpio.LOW)

# Kill the loop with Ctrl-C.
except KeyboardInterrupt:
    # Leave the led turned off.
    print '\nCleaning up...'
    gpio.digitalWrite(pin, gpio.LOW)
예제 #4
0
pin = 13
button = 2

print 'Setting up pins %d and %d...' % (pin, button)

# Set pin 13 to be used as an output GPIO pin.
gpio.pinMode(pin, gpio.OUTPUT)

# Set pin 2 to be used as an input GPIO pin.
gpio.pinMode(button, gpio.INPUT)

print 'Reading from pin %d now...' % button
try:
    while(True):
        # Read the state of the button
        state = gpio.digitalRead(button)

        # If the button is pressed turn ON pin 13
        if state == 1:
            gpio.digitalWrite(pin, gpio.HIGH)

        # If the button is not pressed turn OFF pin 13
        else:
            gpio.digitalWrite(pin, gpio.LOW)

# Kill the loop with Ctrl-C.
except KeyboardInterrupt:
    # Leave the led turned off.
    print '\nCleaning up...'
    gpio.digitalWrite(pin, gpio.LOW)