Modifications
Sauter à la navigation
Sauter à la recherche
← Modification précédente
Modification suivante →
Rasp-Hat-Moteur-Moteurs-Continus
(voir la source)
Version du 30 août 2017 à 20:20
853 octets ajoutés
,
30 août 2017 à 20:20
→Fixer le sens de rotation
Ligne 75 :
Ligne 75 :
== 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:
To set the direction, call '''run(direction)''' where direction is a constant from one of the following:
+
* '''Adafruit_MotorHAT.FORWARD''' - DC motor spins forward
+
* '''Adafruit_MotorHAT.BACKWARD''' - DC motor spins forward
+
* '''Adafruit_MotorHAT.RELEASE''' - DC motor is 'off', not spinning but will also not hold its place.
+
+
<syntaxhighlight lang="python">
+
while (True):
+
print "Forward! "
+
myMotor.run(Adafruit_MotorHAT.FORWARD)
+
+
print "\tSpeed up..."
+
for i in range(255):
+
myMotor.setSpeed(i)
+
time.sleep(0.01)
+
+
print "\tSlow down..."
+
for i in reversed(range(255)):
+
myMotor.setSpeed(i)
+
time.sleep(0.01)
+
+
print "Backward! "
+
myMotor.run(Adafruit_MotorHAT.BACKWARD)
+
+
print "\tSpeed up..."
+
for i in range(255):
+
myMotor.setSpeed(i)
+
time.sleep(0.01)
+
+
print "\tSlow down..."
+
for i in reversed(range(255)):
+
myMotor.setSpeed(i)
+
time.sleep(0.01)
+
+
print "Release"
+
myMotor.run(Adafruit_MotorHAT.RELEASE)
+
time.sleep(1.0)
+
</syntaxhighlight>
{{Rasp-Hat-Moteur-TRAILER}}
{{Rasp-Hat-Moteur-TRAILER}}
Admin
Bureaucrates
,
Administrateurs
29 917
modifications
Menu de navigation
Outils personnels
Se connecter
Espaces de noms
Page
Discussion
Variantes
Affichages
Lire
Voir le texte source
Voir l’historique
Plus
Rechercher
Navigation
ARDUINO
RASPBERRY-PI
[:: PI Hacking ::]
Particle.IO
Micro Python
Imprimante 3D
Actualités
Modifications récentes
Page au hasard
Aide
Outils
Pages spéciales
Version imprimable