StepMotor

  
 #!/usr/bin/python
# -*- coding: UTF-8 -*-

import RPi.GPIO as gpio
from time import sleep

gpio.setmode(gpio.BOARD)
gpio.setup(12, gpio.OUT)
gpio.setup(18, gpio.OUT)
p1 = gpio.PWM(12, 50) # 50 Hz
p2 = gpio.PWM(18, 50) # 50 Hz

p1.start(0)
p2.start(0)

# 0도 
#p.ChangeDutyCycle(3)
#sleep(1)

# 180도
#p.ChangeDutyCycle(12)
#sleep(1)

# 90도
p1.ChangeDutyCycle(7.5)
p2.ChangeDutyCycle(7.5)
p1.ChangeDutyCycle(0)
p2.ChangeDutyCycle(0)

exitLoop = True
while(exitLoop):
 val = input("input(3~7.5~12), #좌우(6), #상하(6) = ")
 if val == "-1":
 exitLoop = False
 else :
 p1.ChangeDutyCycle(float(val.split(',')[0]))
 p2.ChangeDutyCycle(float(val.split(',')[1]))
 sleep(0.2)
 p1.ChangeDutyCycle(0)
 p2.ChangeDutyCycle(0)
 

p1.stop()
p2.stop()
gpio.cleanup()