I am trying to control my Devastator tank, powered by a Raspberry Pi B3, PiHut MotorShield and mini WiFi keyboard. I am receiving the error setupterm cannot find keyboard
. Below is my code:
import curses
import PiMotor
import time
import curses
import os # added so we can shutdown OK
#Name of Individual MOTORS
m1 = PiMotor.Motor("MOTOR1",1)
m2 = PiMotor.Motor("MOTOR2",1)
#To drive all motors together
motorAll = PiMotor.LinkedMotors(m1,m2)
#Names for Individual Arrows
ab = PiMotor.Arrow(1)
al = PiMotor.Arrow(2)
af = PiMotor.Arrow(3)
ar = PiMotor.Arrow(4)
# Get the curses window, turn off echoing of keyboard to screen, turn off
# instant (no waiting) key response, and use special values for curser keys
screen = curses.initscr()
curses.noecho()
curses.cbreak()
screen.keypad(True)
##This segment drives the motors in the direction listed below:
## forward and reverse takes speed in percentage(0-100)
try:
while True:
char = screen.getch()
if char == ord('q'):
break
if char == ord('S'): # Added for shutdown on capital S
os.system ('sudo shutdown now') # shutdown right now!
elif char == curses.KEY_UP:
af.on()
motorAll.forward(100)
elif char == curses.KEY_DOWN:
af.off()
ab.on()
motorAll.reverse(100)
elif char == curses.KEY_RIGHT:
ar.on()
ab.off()
m1.reverse(100)
m2.forward(100)
elif char == curses.KEY_LEFT:
ar.off()
al.on()
m1.forward(100)
m2.reverse(100)
elif char == 10:
motorALL.stop()
except KeyboardInterupt:
#Close down curses properly, inc turn echo back on!
curses.nobreak(); screen.keypad(0); curses.echo(0)
curses.endwin()
I have used “curses” with mini keyboard before, but this time I am getting the error setupterm cannot find keyboard
. Can anyone help me resolve this issue?