from machine import Pin
import time
import uasyncio as asyncio
step_pin = Pin(41, Pin.OUT)
dir_pin = Pin(40, Pin.OUT)
def rotate_motor(steps, direction, speed_us = 1000):
dir_pin.value(direction)
for i in range(steps):
step_pin.value(1)
time.sleep_us(10)
step_pin.value(0)
time.sleep_us(speed_us)
print("--- TEST OBROTU NEMA 17 ---")
print("1. Obrót o 1 pełny obrót (200 kroków) w prawo...")
rotate_motor(200, 1, speed_us=3000)
time.sleep(3) # Przerwa 3 sekundy
print("2. Obrót o 1 pełny obrót (200 kroków) w lewo...")
rotate_motor(200, 0, speed_us=3000)
print("Test zakończony sukcesem!")