Skip to content

Instantly share code, notes, and snippets.

@aansubarkah
Created January 9, 2016 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aansubarkah/074faf3dfdc461c98de5 to your computer and use it in GitHub Desktop.
Save aansubarkah/074faf3dfdc461c98de5 to your computer and use it in GitHub Desktop.
short script to turn on and off LED, with Raspberry Pi 2
import RPi.GPIO as GPIO # library standar pada Rasbian OS
import time
red = 7 # pin 7 disambungkan dengan LED berwarna merah
delay = 3 # delay 3 detik
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(red, GPIO.OUT)
GPIO.output(red, GPIO.HIGH) # beri sinyal HIGH (1) pada pin 7, akan menyalakan LED
time.sleep(delay) # tunggu 3 detik sebelum melakukan perintah selanjutnya
GPIO.output(red, GPIO.LOW) # beri sinyal LOW (0) pada pin 7, mematikan LED
GPIO.cleanup() # program selesai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment