Skip to content

Instantly share code, notes, and snippets.

@dirkjanfaber
Created March 15, 2018 12:49
Show Gist options
  • Save dirkjanfaber/13900fa4c0b63fccc825dfc99671b423 to your computer and use it in GitHub Desktop.
Save dirkjanfaber/13900fa4c0b63fccc825dfc99671b423 to your computer and use it in GitHub Desktop.
Drive a servo via pwm on the Raspberry Pi from bash
#!/bin/bash
# https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/software
gpio -g mode 18 pwm
gpio pwm-ms
gpio pwmc 192
gpio pwmr 2000
while [ 1 -gt 0 ]
do
for i in $(seq 100 200)
do
gpio -g pwm 18 ${i}
done
for i in $(seq 200 -2 100)
do
gpio -g pwm 18 ${i}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment