I have a python code;
Code: Select all
import RPi.GPIO as GPIO # Importing RPi library to use the GPIO pins
from time import sleep # Importing sleep from time library
led_pin = 22 # Initializing the GPIO pin 22 for LED
GPIO.setmode(GPIO.BCM) # We are using the BCM pin numbering
GPIO.setup(led_pin, GPIO.OUT) # Declaring pin 22 as output pin
pwm = GPIO.PWM(led_pin, 100) # Created a PWM object
pwm.start(0) # Started PWM at 0% duty cycle
pwm.ChangeDutyCycle(x) # Change duty cycle