Modifications

Sauter à la navigation Sauter à la recherche
Page créée avec « {{MicroPython-PWM-DRIVER-NAV}} L'exemple ci-dessous contrôle le servo moteur branché sur la sortie #15 du contrôleur (voyez la plan de montage) <syntaxhighlight lang=... »
{{MicroPython-PWM-DRIVER-NAV}}

L'exemple ci-dessous contrôle le servo moteur branché sur la sortie #15 du contrôleur (voyez la plan de montage)

<syntaxhighlight lang="python">
from pyb import I2C
# Import ServoCtrl, classe pour le controleur PMW
from servoctrl import ServoCtrl

# Initialise le bus I2C
i2c = I2C( 2, I2C.MASTER )

# Crée l objet controleur PWM
driver = ServoCtrl( i2c )

# Positionne le servo moteur #15 à un angle de 45 degrés
driver.position( 15, 45 )

# Positionne le servo moteur #15 à un angle de 180 degrés
driver.position( 15, 180 )
</syntaxhighlight>

{{MicroPython-PWM-DRIVER-TRAILER}}
29 917

modifications

Menu de navigation