Kayla T.

asked • 02/07/22

Changing a LED's blinking rate

So initially, the LED starts out by blinking continuously on and off for 0.5s. Then you have to program it so that when the switch is pressed it changes the LED's blink rate from 0.5s to 0.1s. When the switch is released it goes back to its original blink rate of 0.5s.


Here is what I have so far:


import RPi.GPIO as GPIO


from time import sleep


led = 17


button = 25


GPIO.setmode(GPIO.BCM)


GPIO.setup(led, GPIO.OUT)


GPIO.setup(button, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)



while True:


GPIO.ouput(led, GPIO.HIGH)


sleep(0.5)

GPIO.output(led, GPIO.LOW)


sleep(0.5)

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.