Skip to content

Instantly share code, notes, and snippets.

@theterg
Created February 10, 2014 13:38
Show Gist options
  • Select an option

  • Save theterg/8916090 to your computer and use it in GitHub Desktop.

Select an option

Save theterg/8916090 to your computer and use it in GitHub Desktop.
Raspberry pi wiringpi2 pwm test
import wiringpi2 as wiringpi
import sys
import argparse
import time
parser = argparse.ArgumentParser()
# parser.add_argument('--clock', type=int, default=32)
parser.add_argument('--period', type=int, default=200)
parser.add_argument('--pulsewidth', type=int, default=15)
args = parser.parse_args()
# If using BCM GPIO numbers
wiringpi.wiringPiSetupGpio()
wiringpi.softPwmCreate(18, args.pulsewidth, args.period)
# wiringpi.pinMode(18, 2) # pwm only works on GPIO port 18
# wiringpi.pwmSetClock(args.clock)
# wiringpi.pwmSetRange(args.period)
# wiringpi.pwmWrite(18, args.pulsewidth)
time.sleep(5.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment