def handle(msg): chat_id = msg['chat']['id'] command = msg['text'] print 'Got command: %s' % command if command == '/ota': #do some ota jobs from repo, then restart bot.sendMessage(chat_id, str('Upgrading myself,will back soon...')) elif command == '/time': bot.sendMessage(chat_id, str(datetime.datetime.now())) elif command == '/go': agobo.forward(speed) bot.sendMessage(chat_id, str('going forward')) elif command == '/stop': agobo.stop() bot.sendMessage(chat_id, str('stopped')) elif command == '/back': agobo.reverse(speed) bot.sendMessage(chat_id, str('going backward')) elif command == '/play': os.system("omxplayer example.mp3") elif command == "/reboot": # do restart the whole machine bot.sendMessage(chat_id, str('I don't want to risk myself, ah...see you soo..'))
return chr(0x10 + ord(c3) - 65) # 16=Up, 17=Down, 18=Right, 19=Left arrows # End of single character reading #====================================================================== speed = 30 agobo.init() # main loop try: while True: keyp = readkey() if keyp == 'w' or ord(keyp) == 16: agobo.forward(speed) print 'Forward', speed elif keyp == 'z' or ord(keyp) == 17: agobo.reverse(speed) print 'Reverse', speed elif keyp == 's' or ord(keyp) == 18: agobo.spinRight(speed) print 'Spin Right', speed elif keyp == 'a' or ord(keyp) == 19: agobo.spinLeft(speed) print 'Spin Left', speed elif keyp == '.' or keyp == '>': speed = min(100, speed + 10) print 'Speed+', speed elif keyp == ',' or keyp == '<': speed = max(0, speed - 10)
def forward(): agobo.forward(speed) time.sleep(2) agobo.stop()
# Press Ctrl-C to stop # # To check wiring is correct ensure the order of movement as above is correct # Run using: sudo python motorTest.py import agobo, time speed = 80 agobo.init() # main loop try: while True: agobo.forward(speed) print 'Forward' time.sleep(3) agobo.reverse(speed) print 'Reverse' time.sleep(3) agobo.spinRight(speed) print 'Spin Right' time.sleep(3) agobo.spinLeft(speed) print 'Spin Left' time.sleep(3) agobo.stop() print 'Stop' time.sleep(3)