SlideShare a Scribd company logo
1 of 10
Shahed Mehbub
President, Robo Mechatronics Association Bangladesh(RMABD)
Day 3
Raspberry Pi 3 GPIO
5 functions to control GPIOโ€™s
โ€ข GPIO.setmode()
โ€ข GPIO.setwarnings()
โ€ข GPIO.setup()
โ€ข GPIO.input()
โ€ข GPIO.output()
Button input - Wiring
Performing GPIO Input
#import RPi.GPIO as GPIO
From EmulatorGUI import GPIO
import time
GPIO.setmode(GPIO.BCM)
INPUTPIN= 23
GPIO.setup(INPUTPIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
if(GPIO.input(INPUTPIN) == True):
print(โ€˜thisโ€™)
else:
print(โ€˜thatโ€™)
Your Task!!
Write a program that pushing a button
will turn on an LED
Solution
From EmulatorGUI import GPIO
import time
GPIO.setmode(GPIO.BCM)
INPUTPIN= 23
led = 4
GPIO.setup(INPUTPIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
if(GPIO.input(INPUTPIN) == True):
led.on()
else:
led.off()
def led_on():
GPIO.output(led, True)
Def led_of():
GPIO.output(led, False)
Project Demo on Raspberry Pi
โ€ข Buzzer output
โ€ข PIR Motion Sensor
โ€ข Camera Interfacing
Questions???
This slide is available at
http://bit.ly/raspberrypi-workshop-day3

More Related Content

Similar to Control GPIO pins and interface buttons, LEDs on Raspberry Pi

Sensors, actuators and the Raspberry PI using Python
Sensors, actuators and the Raspberry PI using PythonSensors, actuators and the Raspberry PI using Python
Sensors, actuators and the Raspberry PI using PythonDerek Kiong
ย 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development FastBit Embedded Brain Academy
ย 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blinkvishal choudhary
ย 
Script
ScriptScript
Scriptfauzasmg
ย 
Python in raspberry pi
Python in raspberry piPython in raspberry pi
Python in raspberry piSudar Muthu
ย 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using PythonSeggy Segaran
ย 

Similar to Control GPIO pins and interface buttons, LEDs on Raspberry Pi (7)

Sensors, actuators and the Raspberry PI using Python
Sensors, actuators and the Raspberry PI using PythonSensors, actuators and the Raspberry PI using Python
Sensors, actuators and the Raspberry PI using Python
ย 
PPT+.pdf
PPT+.pdfPPT+.pdf
PPT+.pdf
ย 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development
ย 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blink
ย 
Script
ScriptScript
Script
ย 
Python in raspberry pi
Python in raspberry piPython in raspberry pi
Python in raspberry pi
ย 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
ย 

Recently uploaded

(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...motiram463
ย 
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...Call Girls in Nagpur High Profile Call Girls
ย 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
ย 
Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Pooja Nehwal
ย 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
ย 
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)amitlee9823
ย 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
ย 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointGetawu
ย 
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...Pooja Nehwal
ย 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...Call Girls in Nagpur High Profile
ย 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...MOHANI PANDEY
ย 
CHEAP Call Girls in Ashok Nagar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Ashok Nagar  (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Ashok Nagar  (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Ashok Nagar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Pooja Nehwal
ย 
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...amitlee9823
ย 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)kojalkojal131
ย 
Lubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtLubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtdineshkumar430venkat
ย 
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRCALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRdollysharma2066
ย 

Recently uploaded (20)

(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(๐Ÿ‘‰Ridhima)๐Ÿ‘‰VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
ย 
@Delhi ! CAll GIRLS IN Defence Colony ๐Ÿฆ‹ 9999965857 ๐Ÿคฉ Dwarka Call Girls
@Delhi ! CAll GIRLS IN Defence Colony ๐Ÿฆ‹ 9999965857 ๐Ÿคฉ Dwarka Call Girls@Delhi ! CAll GIRLS IN Defence Colony ๐Ÿฆ‹ 9999965857 ๐Ÿคฉ Dwarka Call Girls
@Delhi ! CAll GIRLS IN Defence Colony ๐Ÿฆ‹ 9999965857 ๐Ÿคฉ Dwarka Call Girls
ย 
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
ย 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
ย 
Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006
ย 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
ย 
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)
Escorts Service Arekere โ˜Ž 7737669865โ˜Ž Book Your One night Stand (Bangalore)
ย 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
ย 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power point
ย 
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate โ‚น8.5K) 24ร—7 with Hote...
ย 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
ย 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
ย 
CHEAP Call Girls in Ashok Nagar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Ashok Nagar  (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Ashok Nagar  (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Ashok Nagar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
ย 
๐Ÿ” 9953056974๐Ÿ” Delhi Call Girls in Ajmeri Gate
๐Ÿ” 9953056974๐Ÿ” Delhi Call Girls in Ajmeri Gate๐Ÿ” 9953056974๐Ÿ” Delhi Call Girls in Ajmeri Gate
๐Ÿ” 9953056974๐Ÿ” Delhi Call Girls in Ajmeri Gate
ย 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
ย 
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...
Kothanur Call Girls Service: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bang...
ย 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
ย 
Lubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtLubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabt
ย 
young call girls in Sainik Farm ๐Ÿ” 9953056974 ๐Ÿ” Delhi escort Service
young call girls in Sainik Farm ๐Ÿ” 9953056974 ๐Ÿ” Delhi escort Serviceyoung call girls in Sainik Farm ๐Ÿ” 9953056974 ๐Ÿ” Delhi escort Service
young call girls in Sainik Farm ๐Ÿ” 9953056974 ๐Ÿ” Delhi escort Service
ย 
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRCALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
ย 

Control GPIO pins and interface buttons, LEDs on Raspberry Pi

  • 1. Shahed Mehbub President, Robo Mechatronics Association Bangladesh(RMABD) Day 3
  • 3. 5 functions to control GPIOโ€™s โ€ข GPIO.setmode() โ€ข GPIO.setwarnings() โ€ข GPIO.setup() โ€ข GPIO.input() โ€ข GPIO.output()
  • 4. Button input - Wiring
  • 5. Performing GPIO Input #import RPi.GPIO as GPIO From EmulatorGUI import GPIO import time GPIO.setmode(GPIO.BCM) INPUTPIN= 23 GPIO.setup(INPUTPIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: if(GPIO.input(INPUTPIN) == True): print(โ€˜thisโ€™) else: print(โ€˜thatโ€™)
  • 6. Your Task!! Write a program that pushing a button will turn on an LED
  • 7. Solution From EmulatorGUI import GPIO import time GPIO.setmode(GPIO.BCM) INPUTPIN= 23 led = 4 GPIO.setup(INPUTPIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: if(GPIO.input(INPUTPIN) == True): led.on() else: led.off() def led_on(): GPIO.output(led, True) Def led_of(): GPIO.output(led, False)
  • 8. Project Demo on Raspberry Pi โ€ข Buzzer output โ€ข PIR Motion Sensor โ€ข Camera Interfacing
  • 10. This slide is available at http://bit.ly/raspberrypi-workshop-day3