import curses
from time import sleep
print(‘loading…’)
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, OUTPUT_C, SpeedPercent, MoveTank
from ev3dev2.led import Leds
mb = LargeMotor(OUTPUT_B)
mc = LargeMotor(OUTPUT_C)
def main(stdscr):
# do not wait for input when calling getch
stdscr.nodelay(1)
print(‘ready…’)
while True:
# get keyboard input, returns -1 if none available
c = stdscr.getch()
if c != -1:
# print numeric value
stdscr.addstr(str(c) + ‘ ‘)
if str(c) == ‘119’:
mb.run_forever(speed_sp=900)
mc.run_forever(speed_sp=900)
elif str(c) == ‘115’:
mb.run_forever(speed_sp=-900)
mc.run_forever(speed_sp=-900)
elif str(c) == ’97’:
mc.run_forever(speed_sp=900)
mb.run_forever(speed_sp=-900)
elif str(c) == ‘100’:
mb.run_forever(speed_sp = 900)
mc.run_forever(speed_sp = -900)
stdscr.refresh()
# return curser to start position
stdscr.move(0, 0)
sleep(0.01)
else:
mb.stop()
mc.stop()
if __name__ == ‘__main__’:
curses.wrapper(main)