docs:raspberrypi:controlling_led_s_with_gpio

controlling LED's with GPIO

led-on.py

import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
 
GPIO.output(17,GPIO.HIGH)

led-off.py

import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
 
GPIO.output(17,GPIO.LOW)

led-blink.py

import RPi.GPIO as GPIO
import time
 
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
 
while True:
        GPIO.output(17,GPIO.HIGH)
        time.sleep(1)
        GPIO.output(17,GPIO.LOW)
        time.sleep(1)

led-blink-3.py

import RPi.GPIO as GPIO
import time
 
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(27,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)
 
while True:
        GPIO.output(17,GPIO.HIGH)
        time.sleep(.2)
        GPIO.output(17,GPIO.LOW)
        GPIO.output(27,GPIO.HIGH)
        time.sleep(.2)
        GPIO.output(27,GPIO.LOW)
        GPIO.output(22,GPIO.HIGH)
        time.sleep(.2)
        GPIO.output(22,GPIO.LOW)

led-off-3.py

import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(27,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)
 
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.LOW)
GPIO.output(22,GPIO.LOW)
  • docs/raspberrypi/controlling_led_s_with_gpio.txt
  • Last modified: 2015/09/06 16:53
  • by billh