hello, I've been working on a raspberry pi powered robot I've been trying to write a simple script in python but I have not been able to control the pi from the keyboard
the last part of the script is what I need help with.
the script I've been using
import RPi.GPIO as GPIO
import time
import sys
import Tkinter as tk
def init():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
def w()
GPIO.output(7, False)
GPIO.output(11, True)
GPIO.output(13, True)
GPIO.output(15, False)
time.sleep(tf)
GPIO.cleanup()
def s()
GPIO.output(7, True)
GPIO.output(11, False)
GPIO.output(13, False)
GPIO.output(15, True)
time.sleep(tf)
GPIO.cleanup()
def key_input(event):
init()
print 'Key:' event.char
Key_press = event.char
sleep_time = 0.030
if Key_press.lower() == 'w':
w(sleep_time)
elif key_press.lower() == 's':
s(sleep_time)
else:
pass
command = tk.Tk()
command.bind('<key_press>', key_input)
command.mainloop()




