GPIO input

The program demonstrates the GPIO can be used as input pins also. The PIN 10 is configured to be the input and it is connected from PIN to ground through a button. When the button is pressed the signal connection is established and the input PIN senses the signal after which the message is displayed.


import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10, GPIO.IN)
print GPIO.input(10)
while True:
if ( GPIO.input(10) == False ):
print("Button Pressed")
os.system('date')
print GPIO.input(10)
time.sleep(5)
else:
os.system('clear')
print ("Waiting for you to press a button")
time.sleep(1)