from machine import Pin
from time import sleep
# Define motor pins
motor_pins = {
"1A": Pin(1, Pin.OUT),
"1B": Pin(2, Pin.OUT),
"2A": Pin(3, Pin.OUT),
"2B": Pin(4, Pin.OUT),
}
# Define step and direction pins
step_pin = Pin(20, Pin.OUT)
dir_pin = Pin(21, Pin.OUT)
# Define the number of steps per revolution for your motor
steps_per_revolution = 200
# Function to move the motor continuously in one direction
def move_motor_continuous(direction):
if direction == "CW":
dir_pin.value(1)
else:
dir_pin.value(0)
while True:
step_pin.value(1)
sleep(0.0005) # Adjust this delay for your motor's speed
step_pin.value(0)
sleep(0.0005) # Adjust this delay for your motor's speed
# Rotate the motor continuously in a clockwise direction
move_motor_continuous("CW")