Getting a servo to turn on RPi 400

Thing I have learned:

  1. You don’t need a separate battery pack to power this continuous servo FS90R. You can power it from the 5V pin on the RPi
  2. I need to remember how breadboards work! The valley down the middle is NOT connected underneath
  3. I’m still not sure how pulse width modulation works so can’t control the turning well yet

Pics to follow soon

Useful link: https://stackoverflow.com/questions/45150825/control-continuous-servo-motor-with-raspberry-pi-and-python

Code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
p = GPIO.PWM(17, 50)
p.start(7.5)
try:
  while True:
    p.ChangeDutyCycle(7.5)
    time.sleep(1)
    p.ChangeDutyCycle(12.5)
    time.sleep(1)
    p.ChangeDutyCycle(2.5)
    time.sleep(1)

except KeyboardInterrupt:
  GPIO.cleanup()



  



Simple Guide to the RPi GPIO Header and Pins