Пример #1
0
 def run(self):
     #le code a executer durant l'operation
     distance = spytank.litDistance()
     if distance < 10:
         self.stop = True
         spytank.stop()
         os.system("mpg321 bip.mp3")
     else:
         self.stop = False
     time.sleep(0.2)
Пример #2
0
    def run(self):
        """Code à exécuter pendant l'exécution du thread."""
        while True:
            dist = spytank.litDistance()
            if dist < 25:
                spytank.stop()
                spytank.led(0, 1)
                spytank.led(1, 1)
                spytank.led(2, 1)
                spytank.led(3, 1)
                self.stop = True
            else:
                spytank.led(0, 0)
                spytank.led(1, 0)
                spytank.led(2, 0)
                spytank.led(3, 0)
                self.stop = False

            print(dist)
            time.sleep(0.5)
Пример #3
0
 def run(self):
     while True:
         dist = spytank.litDistance()
         if dist[0] < 30:
             spytank.stop()
         time.sleep(0.5)
Пример #4
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)
spytank.stop()
time.sleep(0.5)
print('gauche')
spytank.gauche(80)
time.sleep(4)
spytank.stop()

print('  --')
print('Distance')
for a in range(10):
    print(spytank.litDistance())
    time.sleep(1)

spytank.close()
Пример #5
0
for i in range(4):
    spytank.led(i, 1)
    time.sleep(0.25)
time.sleep(1)
for i in range(4):
    spytank.led(i, 0)
    time.sleep(0.25)

spytank.avance(150)
time.sleep(1)
spytank.stop()
time.sleep(1)
spytank.recule(150)
time.sleep(1)
spytank.stop()
time.sleep(1)
spytank.droite(150)
time.sleep(1)
spytank.stop()
time.sleep(1)
print(spytank.gauche(150))
time.sleep(1)
print(spytank.stop())


for i in range(10):
    print( "distance : " + str(spytank.litDistance()) )
    time.sleep(1)