SlideShare a Scribd company logo
www.techvilla.org.in
TECHVILLA
www.techvilla.org.in
www.techvilla.org.in
Interfacing a push button
 read data through GPIO.
 read the value of a push button on a breadboard.
 Writing a code to detect a push button being switched on/off .
www.techvilla.org.in
Button circuit
www.techvilla.org.in
Writing the code
 On the terminal type : nano button.py
 Write following code.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)

More Related Content

PDF
Python code for Push button using Raspberry Pi
PDF
Python code for Buzzer Control using Raspberry Pi
PPTX
Interfacing two wire adc0831 to raspberry pi2 / Pi3
PPT
Led with raspberry pi
PPTX
Raspberry pi Part 18
PPTX
Abril, Angelinn Meryl V. (Storyline Plot)
PPTX
Abril, Angelinn Meryl V. (Types of Character in Literature)
PPTX
Raspberry pi Part 24
Python code for Push button using Raspberry Pi
Python code for Buzzer Control using Raspberry Pi
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Led with raspberry pi
Raspberry pi Part 18
Abril, Angelinn Meryl V. (Storyline Plot)
Abril, Angelinn Meryl V. (Types of Character in Literature)
Raspberry pi Part 24

Viewers also liked (12)

PPTX
Abril, Angelinn Meryl V.( Types of Character in Literature)
PPT
Timer Part 11
PPTX
Abril, Angelinn Meryl V. (Storyline Plot)
PPTX
Esperienze concrete di sviluppo e cura del territorio attraverso il PSR
PPTX
Raspberry pi Part 6
PPTX
corruption
PPTX
Rasperry pi Part 7
PPTX
Abril, Angelinn Meryl V. (Types of Character in Literature)
PPTX
Rasperry pi Part 12
PPTX
Abril, Angelinn Meryl V. (Types of Literature Conflict)
PPT
Led matrix and relay interfacing Part-3
PPTX
Abril, Angelinn Meryl V. ( Types of Literary Conflict)
Abril, Angelinn Meryl V.( Types of Character in Literature)
Timer Part 11
Abril, Angelinn Meryl V. (Storyline Plot)
Esperienze concrete di sviluppo e cura del territorio attraverso il PSR
Raspberry pi Part 6
corruption
Rasperry pi Part 7
Abril, Angelinn Meryl V. (Types of Character in Literature)
Rasperry pi Part 12
Abril, Angelinn Meryl V. (Types of Literature Conflict)
Led matrix and relay interfacing Part-3
Abril, Angelinn Meryl V. ( Types of Literary Conflict)
Ad

More from Techvilla (20)

PPTX
Raspberry pi Part 26
PPTX
Raspberry pi Part 25
PPTX
Raspberry pi Part 23
PPTX
Raspberry pi Part 22
PPTX
Raspberry pi Part 21
PPTX
Raspberry pi Part 20
PPTX
Raspberry pi Part 19
PPTX
Raspberry pi Part 17
PPTX
Raspberry pi Part 16
PPTX
Rasperry pi Part 13
PPTX
Rasperry pi Part 10
PPTX
Rasperry pi Part 9
PPTX
Rasperry pi Part 8
PPTX
Raspberry pi Part 5
PPTX
Raspberry pi Part 4
PPTX
Raspberry pi Part 3
PPTX
Raspberry pi Part 1
PPT
I2C And SPI Part-23
PPT
WIFI MODEM Part-22
PPT
EEPROM Part-21
Raspberry pi Part 26
Raspberry pi Part 25
Raspberry pi Part 23
Raspberry pi Part 22
Raspberry pi Part 21
Raspberry pi Part 20
Raspberry pi Part 19
Raspberry pi Part 17
Raspberry pi Part 16
Rasperry pi Part 13
Rasperry pi Part 10
Rasperry pi Part 9
Rasperry pi Part 8
Raspberry pi Part 5
Raspberry pi Part 4
Raspberry pi Part 3
Raspberry pi Part 1
I2C And SPI Part-23
WIFI MODEM Part-22
EEPROM Part-21
Ad

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PPTX
Artificial Intelligence
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Geodesy 1.pptx...............................................
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Sustainable Sites - Green Building Construction
PDF
Well-logging-methods_new................
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT on Performance Review to get promotions
Artificial Intelligence
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Internet of Things (IOT) - A guide to understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Embodied AI: Ushering in the Next Era of Intelligent Systems
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Mechanical Engineering MATERIALS Selection
Geodesy 1.pptx...............................................
CH1 Production IntroductoryConcepts.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Sustainable Sites - Green Building Construction
Well-logging-methods_new................
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Safety Seminar civil to be ensured for safe working.
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf

Rasperry pi Part 15