def UpDown2(): servo.position(2, 180)
import servo from machine import I2C, Pin import time i2c = I2C(-1, scl=Pin(22), sda=Pin(21)) # Create a simple PCA9685 class instance. servo = servo.Servos(i2c) servo.position(0, degrees=100)
def UpDown(): servo.position(2, 0)
def UpDown1(): servo.position(2, 90)
def ForBack1(): servo.position(1, 90)
def ForBack2(): servo.position(1, 180)
def OpenClose1(): servo.position(0, 90)
def ForBack(): servo.position(1, 0)
def OpenClose(): servo.position(0, 0)
def LeftRight2(): servo.position(3, 180)
def LeftRight1(): servo.position(3, 90)
def LeftRight(): servo.position(3, 0)
esp.osdebug(None) import gc AIN1 = Pin(15, Pin.OUT) AIN2 = Pin(2, Pin.OUT) BIN1 = Pin(0, Pin.OUT) BIN2 = Pin(4, Pin.OUT) PWMPinA = PWM(Pin(16), freq=980) PWMPinB = PWM(Pin(17), freq=980) i2c = I2C(-1, scl=Pin(22), sda=Pin(21)) servo = servo.Servos(i2c) servo.position(0, degrees=1) servo.position(1, degrees=1) servo.position(2, degrees=1) servo.position(3, degrees=1) def ModeStop(): AIN1.off() AIN2.off() BIN1.off() BIN2.off() def ModeForward(): AIN1.on() AIN2.off()