from MotorModule import Motor import keyPressModule as kp import JoystickModule as js from time import sleep ############################## motor= Motor(2,3,4,17,27,22) movement = 'Joystick' ############################## kp.init() def main(): if movement == 'Joystick': jsVal = js.getJS() if jsVal['L1']==1: motor.move(0.2,0,0.1) elif jsVal['x']==1: motor.move(-0.2,0,0.1) elif jsVal['o']==1: motor.move(0.2,-0.1,0.1) elif jsVal['s']==1: motor.move(0.2,0.1,0.1) else: motor.stop(0.1) #motor.move(-(jsVal['L1']),-(jsVal['o']),0.1) #print(jsVal) #sleep(0.05) else: #print(kp.getKey('s')) if kp.getKey('UP'): motor.move(0.6,0,0.1) elif kp.getKey('DOWN'): motor.move(-0.6,0,0.1) elif kp.getKey('LEFT'): motor.move(0.5,0.1,0.1) elif kp.getKey('RIGHT'): motor.move(0.5,-0.1,0.1) if __name__ == '__main__': while True: main()