PIR Sensor and Keyboard Space Key
Posted: Thu Nov 06, 2014 2:02 am
I am using both models - B and B+ - in a kiosk type environment. I am also using a PIR sensor (http://www.amazon.com/gp/product/B00KKR ... UTF8&psc=1) to turn on the screen on when the sensor is tripped. For the most part, this works.
Where I am having issue is here - When the sensor is connected and the python code I have is running, anytime I use a keyboard to type something out (URL, login info, file editing), I am automatically getting spaces added at the rate of 1 space per second. I had originally thought it was related to my USB keyboard/track pad combo.
Here is my python code:
Where I am having issue is here - When the sensor is connected and the python code I have is running, anytime I use a keyboard to type something out (URL, login info, file editing), I am automatically getting spaces added at the rate of 1 space per second. I had originally thought it was related to my USB keyboard/track pad combo.
Here is my python code:
Code: Select all
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os
import subprocess
from subprocess import Popen, PIPE
sensorPin = 7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
prevState = False
currState = False
key_seq = '''key A'''
def keypress(sequence):
p = Popen(['xte'], stdin=PIPE)
p.communicate(input=sequence)
while True:
time.sleep(1)
prevState = "LOW"
currState = GPIO.input(sensorPin)
if currState != prevState:
newState = "HIGH" if currState else "LOW"
if currState:
keypress(key_seq)/code]
I am sure now that this is directly related to how I am using the "key_seq" to turn the screen back on I am just not sure how or why.
Where can I look to get more info on this?