Created
January 27, 2022 16:08
-
-
Save pertoft/2669cc4787e81bbf691fae58c8ee1671 to your computer and use it in GitHub Desktop.
Raspberry PI 4 PWM example
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 | |
from time import sleep | |
ledpin = 12 # PWM pin connected to LED | |
GPIO.setwarnings(False) #disable warnings | |
GPIO.setmode(GPIO.BOARD) #set pin numbering system | |
GPIO.setup(ledpin,GPIO.OUT) | |
pi_pwm = GPIO.PWM(ledpin,1000) #create PWM instance with frequency | |
pi_pwm.start(0) #start PWM of required Duty Cycle | |
pi_pwm.ChangeDutyCycle(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment