Ligne 74 : |
Ligne 74 : |
| | | |
| == Fixer le sens de rotation == | | == Fixer le sens de rotation == |
− | To set the direction, call '''run(direction)''' where direction is a constant from one of the following:
| + | Pour fixer le sens de rotation, on appelle la fonction '''run(direction)''' où ''direction'' est une constante pouvant prendre l'une des valeurs suivantes: |
− | * '''Adafruit_MotorHAT.FORWARD''' - DC motor spins forward | + | * '''Adafruit_MotorHAT.FORWARD''' - Moteur continu tourne en marche avant |
− | * '''Adafruit_MotorHAT.BACKWARD''' - DC motor spins forward | + | * '''Adafruit_MotorHAT.BACKWARD''' - Moteur continu tourne en marche arrière |
− | * '''Adafruit_MotorHAT.RELEASE''' - DC motor is 'off', not spinning but will also not hold its place. | + | * '''Adafruit_MotorHAT.RELEASE''' - Moteur continu est désactivé (à l'arrêt). Il n'est plus propulsé mais ne sera pas maintenu bloqué à l'arrêt. |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| while (True): | | while (True): |
− | print "Forward! " | + | print "Forward! (marche avant)" |
| myMotor.run(Adafruit_MotorHAT.FORWARD) | | myMotor.run(Adafruit_MotorHAT.FORWARD) |
| | | |
− | print "\tSpeed up..." | + | print "\tSpeed up... (accélérer)" |
| for i in range(255): | | for i in range(255): |
| myMotor.setSpeed(i) | | myMotor.setSpeed(i) |
| time.sleep(0.01) | | time.sleep(0.01) |
| | | |
− | print "\tSlow down..." | + | print "\tSlow down... (ralentir)" |
| for i in reversed(range(255)): | | for i in reversed(range(255)): |
| myMotor.setSpeed(i) | | myMotor.setSpeed(i) |
| time.sleep(0.01) | | time.sleep(0.01) |
| | | |
− | print "Backward! " | + | print "Backward! (marche arrière)" |
| myMotor.run(Adafruit_MotorHAT.BACKWARD) | | myMotor.run(Adafruit_MotorHAT.BACKWARD) |
| | | |
− | print "\tSpeed up..." | + | print "\tSpeed up... (accélérer)" |
| for i in range(255): | | for i in range(255): |
| myMotor.setSpeed(i) | | myMotor.setSpeed(i) |
| time.sleep(0.01) | | time.sleep(0.01) |
| | | |
− | print "\tSlow down..." | + | print "\tSlow down... (ralentir)" |
| for i in reversed(range(255)): | | for i in reversed(range(255)): |
| myMotor.setSpeed(i) | | myMotor.setSpeed(i) |
| time.sleep(0.01) | | time.sleep(0.01) |
| | | |
− | print "Release" | + | print "Release (arrêter les moteurs)" |
| myMotor.run(Adafruit_MotorHAT.RELEASE) | | myMotor.run(Adafruit_MotorHAT.RELEASE) |
| time.sleep(1.0) | | time.sleep(1.0) |