import RPi.GPIO as GPIO
import time
# Set up GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT) # GPIO pin 17 for the first LED
GPIO.setup(18, GPIO.OUT) # GPIO pin 18 for the second LED
def blink_leds():
try:
for _ in range(4): # Blink four times
GPIO.output(17, GPIO.HIGH) # Turn on the first LED
GPIO.output(18, GPIO.HIGH) # Turn on the second LED
time.sleep(1) # Delay for one second
GPIO.output(17, GPIO.LOW) # Turn off the first LED
GPIO.output(18, GPIO.LOW) # Turn off the second LED
time.sleep(1) # Delay for one second
GPIO.cleanup() # Clean up GPIO on program exit
except KeyboardInterrupt:
GPIO.cleanup() # Clean up GPIO on keyboard interrupt
if __name__ == "__main__":
blink_leds()