Skip to content

Instantly share code, notes, and snippets.

@ikizoglu
Created February 5, 2026 21:31
Show Gist options
  • Select an option

  • Save ikizoglu/afff36ee63e3a0d2ad69db41fcd9fd1c to your computer and use it in GitHub Desktop.

Select an option

Save ikizoglu/afff36ee63e3a0d2ad69db41fcd9fd1c to your computer and use it in GitHub Desktop.
#RaspberryPi LED + Buton Kodu
#RaspberryPi LED + Buton Kodu
#--------------------------------
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# Set pin 10 to be an input pin and set initial value to be pulled low (off)
LED_PIN = 40 # GPIO21 (Pin 40)
GPIO.setup(LED_PIN, GPIO.OUT)
while True:
if GPIO.input(10) == GPIO.HIGH:
print("Button was pushed!")
print("LED turned on!")
GPIO.output(LED_PIN, GPIO.HIGH)
time.sleep(1)
else:
print("LED turned off!")
GPIO.output(LED_PIN, GPIO.LOW)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment