import spytank import time spytank.init('/dev/ttyUSB0') print('led gauche') spytank.led(spytank.LED_GAUCHE, 1) time.sleep(0.3) spytank.led(spytank.LED_GAUCHE, 0) time.sleep(0.3) print(' --') print('led droite') spytank.led(spytank.LED_DROITE, 1) time.sleep(0.3) spytank.led(spytank.LED_DROITE, 0) time.sleep(0.3) print(' --') print('avance') spytank.avance(80) time.sleep(4) spytank.stop() time.sleep(0.5) print('recule') spytank.recule(80) time.sleep(4) spytank.stop() time.sleep(0.5) print('droite') spytank.droite(80) time.sleep(4)
#!/usr/bin/env python import spytank spytank.init() vitesse = 100 direction = 1 def commande(lettre): global vitesse global direction if lettre == "z": spytank.avance(vitesse) direction = 1 elif lettre == "s": spytank.recule(vitesse) direction = 2 elif lettre == "q": spytank.gauche(vitesse) direction = 3 elif lettre == "d": spytank.droite(vitesse) direction = 4 elif lettre == "x": spytank.stop() direction = 5 elif lettre == "a": if vitesse < 100: vitesse = vitesse + 10 if direction == 1: