Skip to content

Instantly share code, notes, and snippets.

@getelectronics
Created December 20, 2018 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getelectronics/9f724f55194b0c800b246e28553acc4d to your computer and use it in GitHub Desktop.
Save getelectronics/9f724f55194b0c800b246e28553acc4d to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
#The output pin
GPIO_PIN = 21
GPIO.setup(GPIO_PIN, GPIO.OUT)
pwm = GPIO.PWM(GPIO_PIN, 500)
pwm.start(50)
# The program will wait for the input of a new frequency.
try:
while(True):
print "----------------------------------------"
print "Current frequency: %d" % 500
Frequency = input("Please input a new frequency (50-5000):")
pwm.ChangeFrequency(Frequency)
except KeyboardInterrupt:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment