Monday, January 30, 2017

Raspberry Pi - GPIO (Button Down Input, LED Output)

This code will take button press down input from GPIO pin 11 and LED output to pin 15.

BreadBoard Setup
PIN Mapping
Pi 11 = Wedge GP17
Pi 15 = Wedge GP22

Python Code:
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(11,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(15,GPIO.OUT)
GPIO.output(15,0)

try:
    while True:
        if(GPIO.input(11) == 1):
            GPIO.output(15,1)
        else:
            GPIO.output(15,0)

except KeyboardInterrupt:
    GPIO.cleanup()

1 comment:

  1. Thanks for giving the information it is useful for me.
    Crafsol develop the mobile application for mobile devices by using the SAP technology.
    Enterprise Mobility

    ReplyDelete