I want to make a simple thread that listens if a Button is pressed or not.
I receive the error ImportError No module named thread
.
import RPi.GPIO as GPIO
import time
import thread
GPIO.setmode(GPIO.BCM)
GPIO.setup(2,GPIO.OUT)
GPIO.setup(3,GPIO.OUT)
GPIO.setup(17,GPIO.IN)
def pushButton():
while True:
if GPIO.input(17) == 1:
print("on")
else:
print("of")
while True:
GPIO.output(2,1)
GPIO.output(3,1)
time.sleep(1);
GPIO.output(2,0)
GPIO.output(3,0)
time.sleep(1)
thread.start(pushButton,())
GPIO.cleanup()
python --version
to see. FYI, thethread
module was renamed_thread
in version 3 of python.Traceback