#servo_sg90.py
# red-pin40 VBUS brown-GND orange-pin0
from machine import PWM, Pin
import time
servo1 = PWM(Pin(0))
servo1.freq(50)
max_duty = 65025
dig_0 = 0.0725 #0°
dig_90 = 0.12 #90°
while True:
servo1.duty_u16(int(max_duty*dig_0))
time.sleep(1)
servo1.duty_u16(int(max_duty*dig_90))
time.sleep(1)
#twomotors_mx1508.py
# IN1-pin1 IN2-pin2 IN3-pin3 IN4-pin4
import utime
from machine import Pin
IN1 = Pin(1, Pin.OUT)
IN2 = Pin(2, Pin.OUT)
IN3 = Pin(3, Pin.OUT)
IN4 = Pin(4, Pin.OUT)
while True:
IN1.high()
IN2.low()
IN3.high()
IN4.low()
utime.sleep(2)
IN1.high()
IN2.high()
IN3.high()
IN4.high()
utime.sleep(2)
IN1.low()
IN2.high()
IN3.low()
IN4.high()
utime.sleep(2)
IN1.low()
IN2.low()
IN3.low()
IN4.low()
utime.sleep(2)
stepper_lu2003.py
#IN1-pin1 IN2-pin2 IN3-pin3 IN4-pin4
from machine import Pin
from time import sleep
IN1 = Pin(1,Pin.OUT)
IN2 = Pin(2,Pin.OUT)
IN3 = Pin(3,Pin.OUT)
IN4 = Pin(4,Pin.OUT)
pins = [IN1, IN2, IN3, IN4]
sequence = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
while True:
for step in sequence:
for i in range(len(pins)):
pins[i].value(step[i])
sleep(0.001)
0 件のコメント:
コメントを投稿