0

I'm new to Python and just go this Raspberry Pi, and need help blinking this led. I have got it to where the LED will blink once( Turn on for a second, then turn off). I need some help so when I hit run the LED will blink continuously.

Here is my code that I have so far -

#blink.py
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, True)
time.sleep(.5)
GPIO.output(4, False)
2

Just put the on/off part of the code in an endless loop:

#blink.py
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
while True:
    GPIO.output(4, True)
    time.sleep(.5)
    GPIO.output(4, False)
    time.sleep(.5)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.