• # modification de la fonction stop

    Posté par . En réponse au message problème rebond moteur Python 3 COO. Évalué à 1.

    pour que la fonction stop soit réellement opérationnelle et que le moteur ralentisse en s'arrêtant , voici le code complet

    def ccMan(self,ccDir=""):
     global Moteur_status
     self.Moteur_status = not self.Moteur_status
     GPIO.output(self.MoteurOutputPinL, self.Moteur_status)
     GPIO.output(self.MoteurOutputPinR, self.Moteur_status)
     GPIO.output(self.MoteurOutputPinN, self.Moteur_status)
     if self.Moteur_status == 1 or ccDir=="ccleft":
     GPIO.output(self.MoteurOutputPinL,GPIO.HIGH)
     GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
     GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
     for dc in range(0, 101, 10):
     self.V1.ChangeDutyCycle(dc)
     time.sleep(self.t) 
     if self.Moteur_status == 0 or ccDir=="ccright":
     GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
     GPIO.output(self.MoteurOutputPinR,GPIO.HIGH)
     GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
     for dc in range(0, 101, 10):
     self.V1.ChangeDutyCycle(dc)
     time.sleep(self.t)
    def ccManStop(self,ccstop=""):
     global Moteur_status
     GPIO.output(self.MoteurOutputPinL, self.Moteur_status)
     GPIO.output(self.MoteurOutputPinR, self.Moteur_status)
     GPIO.output(self.MoteurOutputPinN, self.Moteur_status)
     if self.Moteur_status == 1 and ccstop=="ccstop":
     GPIO.output(self.MoteurOutputPinL,GPIO.HIGH)
     GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
     GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
     for dc in range(100, -1, -10):
     self.V1.ChangeDutyCycle(dc)
     time.sleep(self.t) 
     if self.Moteur_status == 0 and ccstop=="ccstop":
     GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
     GPIO.output(self.MoteurOutputPinR,GPIO.HIGH)
     GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
     for dc in range(100, -1, -10):
     self.V1.ChangeDutyCycle(dc)
     time.sleep(self.t)
    def loop(self):
     GPIO.add_event_detect(self.TiltSensorPin, GPIO.FALLING, callback=self.ccMan, bouncetime = 10000)
     GPIO.add_event_detect(self.TiltSensorPin2, GPIO.FALLING, callback=self.ccMan, bouncetime = 10000)

    je me suis aidé tout seul ;-) mais si ça peut servir à d'autre