Created
March 28, 2021 15:39
-
-
Save aslucki/d18cfe9be2687dec9a64c62d39931d24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(33, GPIO.OUT) | |
# Setup 50Hz frequency PWM signal on the pin 33. | |
pwm = GPIO.PWM(33, 50) | |
pwm.start(0) | |
while True: | |
try: | |
duty_cycle = input("Set the duty cycle and press enter: ") | |
duty_cycle = float(duty_cycle) | |
print("The DC is:", duty_cycle) | |
pwm.ChangeDutyCycle(duty_cycle) | |
except KeyboardInterrupt: | |
break | |
pwm.stop() | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment