LoginSignup
0
1

More than 5 years have passed since last update.

servo simple RPi

Posted at
servo_simple.py
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
servo_pin = 3
GPIO.setup(3, GPIO.OUT)
servo = GPIO.PWM(3, 50)

servo.start(0)

servo.ChangeDutyCycle(2.0)
time.sleep(2.0)
servo.ChangeDutyCycle(12.0)
time.sleep(2.0)
servo.ChangeDutyCycle(2.0)
time.sleep(1.0)
servo.ChangeDutyCycle(12.0)
time.sleep(2.0)

servo.stop()

GPIO.cleanup()

参考: http://rpi.science.uoit.ca/lab/servo/
PWMのコマンドの意味は

In the above case we have instantiated the PWM module for the pin number 12 with a frequency of 50Hz. That frequency was selected because the servo motor expect a pulse every 20ms (period), that means 50 pulses per second or Hertz.

だそうです.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1