1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #!/usr/bin/env python
import threading
import time
import RPi.GPIO as GPIO # bibliothèques du GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(22,GPIO.OUT)
GPIO.setwarnings(False)
entre = ''
Etat_moteur = 0
def Commande():
while 1:
print("commande")
if entre == 'z':
Etat_moteur = 1
else:
Etat_moteur = 0
def Moteur():
while 1: # Si Etat_moteur est a 1 les roues mettent en marche, les tempo sont pour faire un PWM
GPIO.output(22,Etat_moteur) # sortie au niveau logique haut sur la broche 22
time.sleep(0.0030)
GPIO.output(22,0) # sortie au niveau logique bas sur la broche 22
time.sleep(0.0070)
thread_1 = Commande()
thread_2 = Moteur()
thread_1.start()
thread_2.start()
while 1:
entre = raw_input #On demande a l'utilisateur d'entrer l'ordre.
time.sleep(1) |
Partager