Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import RPi.GPIO as IO #calling header file which helps us use GPIO’s of PI
  2. import time #calling time to provide delays in program
  3. IO.setwarnings(False) #do not show any warnings
  4. IO.setmode (IO.BCM) #we are programming the GPIO by BCM pin numbers. (PIN35 as ‘GPIO19’)
  5. IO.setup(19,IO.OUT) # initialize GPIO19 as an output.
  6. p = IO.PWM(19,100) #GPIO19 as PWM output, with 100Hz frequency
  7. p.start(0) #generate PWM signal with 0% duty cycle
  8. while 1: #execute loop forever
  9. for x in range (50): #execute loop for 50 times, x being incremented from 0 to 49.
  10. p.ChangeDutyCycle(x) #change duty cycle for varying the brightness of LED.
  11. time.sleep(0.1) #sleep for 100m second
  12.  
  13. for x in range (50): #execute loop for 50 times, x being incremented from 0 to 49.
  14. p.ChangeDutyCycle(50-x) #change duty cycle for changing the brightness of LED.
  15. time.sleep(0.1) #sleep for 100m second
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement