Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

servo simple RPi

More than 3 years have passed since last update.
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.

だそうです.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away