Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
697 B
0
Indexable
Never
import RPi.GPIO as GPIO
import time

# Set up GPIO using BCM numbering
GPIO.setmode(GPIO.BCM)

# Define the GPIO pin number
gpio_pin = 18

# Set up the GPIO pin as an output
GPIO.setup(gpio_pin, GPIO.OUT)

try:
    while True:
        # Connect the wire to ground (set GPIO pin low)
        GPIO.output(gpio_pin, GPIO.LOW)
        
        # Wait for a period of time (e.g., 1 second)
        time.sleep(1)
        
        # Disconnect the wire from ground (set GPIO pin high)
        GPIO.output(gpio_pin, GPIO.HIGH)
        
        # Wait for another period of time
        time.sleep(1)

except KeyboardInterrupt:
    # Clean up GPIO on Ctrl+C
    GPIO.cleanup()
Leave a Comment