Controlling Brightness Of Led Using PWM with Raspberry Pi
Code :
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(21,GPIO.OUT)
p = GPIO.PWM(21,50)
p.start(0)
while True :
for i in range(100) :
p.ChangeDutyCycle(i)
time.sleep(0.05)
for i in range(100) :
p.ChangeDutyCycle(100-i)
time.sleep(0.05)
Output :
Code :
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(21,GPIO.OUT)
p = GPIO.PWM(21,50)
p.start(0)
while True :
for i in range(100) :
p.ChangeDutyCycle(i)
time.sleep(0.05)
for i in range(100) :
p.ChangeDutyCycle(100-i)
time.sleep(0.05)
Output :
No comments:
Post a Comment