SlideShare a Scribd company logo
1 of 7
1
Raspberry Pi Tutorial #2
- Measuring the light -
Dong Ho Son
POSTECH
Pohang, Korea
donghoson@postech.ac.kr
2
Measuring the light - Overview
 Let’s use the sensor
• Sensor : Analog  Digital
− Analog : continuous
− Digital : discrete
• Photoresistor 3 pin (or light-dependent resistor, LDR)
− A light-controlled variable resistor
− The resistance increases/decreases according to the brightness of light
• Let’s configure the circuit
− The brightness of the LED is changed according to the brightness of the environment
− If dark, the LED is turned on
− If bright, the LED is turned off
3
Measuring the light - Overview
 Measure the brightness of light and turn on/off the LED
 Necessary Components
• 1 x Raspberry Pi
• 1 x Breadboard
• 1 x red LED
• 1 x Resistor
• 1 x Photoresistor 3 pin
• Jumper cables
Anode
Cathode
GND
OUT
VCC
4
Measuring the light – Circuit configuration
 Ground pin  the cathode of the LED
 The anode of the LED  a ballast resistor
 The ballast resistor  the pin GPIO 18
 VCC of photoresistor  3.3V
 OUT of photoresistor  the pin GPIO 17
 GND of photoresistor  Ground pin
Cathode Anode
5
Measuring the light - Python
 Import RPi.GPIO as GPIO
• Import Python GPIO module
 GPIO.setmode(GPIO.BCM)
• Use Broadcom chip number
 GPIO.setup(17, GPIO.IN)
• Select GPIO #17 as input pin
• Measure the brightness using sensor
 GPIO.setup(18, GPIO.OUT)
• Select GPIO #18 as output pin
• Turn on/off the LED
6
Measuring the light - Python
 GPIO.input(17)
• Return 0(bright) or 1(dark)
 GPIO.output(18, GPIO.LOW)
• Turn off the LED
 GPIO.output(18, GPIO.HIGH)
• Turn on the LED
 time.sleep(1)
• Delay for 1 second
7
Measuring the light - Result
 If bright, the LED is turned off
 If dark, the LED is turned on
Cathode Anode

More Related Content

Similar to Raspberry pi tutorial #2

Simplest Continuity Tester
Simplest Continuity TesterSimplest Continuity Tester
Simplest Continuity TesterMuhammad Khan
 
Automatic street light circuit using ldr
Automatic street light circuit using ldrAutomatic street light circuit using ldr
Automatic street light circuit using ldrSmartxProKits
 
Automatic street light using ldr and relay
Automatic street light using ldr and relayAutomatic street light using ldr and relay
Automatic street light using ldr and relayShivam Raidas
 
Automatic light control Using LDR
Automatic light control Using LDRAutomatic light control Using LDR
Automatic light control Using LDRBadrul Alam
 
FUNDAMENTAL OF ELECTRONICS AND HARDWARE
FUNDAMENTAL OF ELECTRONICS AND HARDWAREFUNDAMENTAL OF ELECTRONICS AND HARDWARE
FUNDAMENTAL OF ELECTRONICS AND HARDWAREVikrant Thakur
 
BASIC ELECTRONICSBasic electronics a by abdul rahaman
BASIC ELECTRONICSBasic electronics a by abdul rahamanBASIC ELECTRONICSBasic electronics a by abdul rahaman
BASIC ELECTRONICSBasic electronics a by abdul rahamanAbdul45678
 
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdf
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdfIoT_IO1_3 Getting familiar with Hardware - Sensors.pdf
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdfDanishMahmood23
 
21ELN24 [PROJECT ].pptx
21ELN24 [PROJECT ].pptx21ELN24 [PROJECT ].pptx
21ELN24 [PROJECT ].pptxTLRTHR
 
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptx
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptxPRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptx
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptxNURHADIALHAKIMBINISM
 
Analog Electronics ppt on Photo Diodes and LED by Being topper
Analog Electronics  ppt on Photo Diodes  and LED by Being topperAnalog Electronics  ppt on Photo Diodes  and LED by Being topper
Analog Electronics ppt on Photo Diodes and LED by Being topperVipin Kumar
 
report on intelligent energy conservation system
report on intelligent energy conservation system report on intelligent energy conservation system
report on intelligent energy conservation system vyomesh upadhyay
 

Similar to Raspberry pi tutorial #2 (20)

Basics of elec.
Basics of elec.Basics of elec.
Basics of elec.
 
Basics of elec.
Basics of elec.Basics of elec.
Basics of elec.
 
Measurements upload
Measurements uploadMeasurements upload
Measurements upload
 
Simplest Continuity Tester
Simplest Continuity TesterSimplest Continuity Tester
Simplest Continuity Tester
 
Automatic street light circuit using ldr
Automatic street light circuit using ldrAutomatic street light circuit using ldr
Automatic street light circuit using ldr
 
Automatic street light using ldr and relay
Automatic street light using ldr and relayAutomatic street light using ldr and relay
Automatic street light using ldr and relay
 
Chapter33 (1).ppt
Chapter33 (1).pptChapter33 (1).ppt
Chapter33 (1).ppt
 
Basics of elec.
Basics of elec.Basics of elec.
Basics of elec.
 
Basics of electronics
Basics of electronicsBasics of electronics
Basics of electronics
 
Automatic light control Using LDR
Automatic light control Using LDRAutomatic light control Using LDR
Automatic light control Using LDR
 
FUNDAMENTAL OF ELECTRONICS AND HARDWARE
FUNDAMENTAL OF ELECTRONICS AND HARDWAREFUNDAMENTAL OF ELECTRONICS AND HARDWARE
FUNDAMENTAL OF ELECTRONICS AND HARDWARE
 
lab_2.pdf
lab_2.pdflab_2.pdf
lab_2.pdf
 
BASIC ELECTRONICSBasic electronics a by abdul rahaman
BASIC ELECTRONICSBasic electronics a by abdul rahamanBASIC ELECTRONICSBasic electronics a by abdul rahaman
BASIC ELECTRONICSBasic electronics a by abdul rahaman
 
ELECTRONIC EYE FOR NIGHT DEVICE SWITCHING USING 555 TIMER
ELECTRONIC EYE FOR NIGHT DEVICE SWITCHING USING 555 TIMERELECTRONIC EYE FOR NIGHT DEVICE SWITCHING USING 555 TIMER
ELECTRONIC EYE FOR NIGHT DEVICE SWITCHING USING 555 TIMER
 
Basic_electronics (2).pptx
Basic_electronics (2).pptxBasic_electronics (2).pptx
Basic_electronics (2).pptx
 
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdf
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdfIoT_IO1_3 Getting familiar with Hardware - Sensors.pdf
IoT_IO1_3 Getting familiar with Hardware - Sensors.pdf
 
21ELN24 [PROJECT ].pptx
21ELN24 [PROJECT ].pptx21ELN24 [PROJECT ].pptx
21ELN24 [PROJECT ].pptx
 
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptx
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptxPRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptx
PRESENTATION PRACTICAL TASK (A) MINI PROJECT-2.pptx
 
Analog Electronics ppt on Photo Diodes and LED by Being topper
Analog Electronics  ppt on Photo Diodes  and LED by Being topperAnalog Electronics  ppt on Photo Diodes  and LED by Being topper
Analog Electronics ppt on Photo Diodes and LED by Being topper
 
report on intelligent energy conservation system
report on intelligent energy conservation system report on intelligent energy conservation system
report on intelligent energy conservation system
 

More from 동호 손

Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started동호 손
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi동호 손
 
Arduino tutorial #1
Arduino tutorial #1Arduino tutorial #1
Arduino tutorial #1동호 손
 
Arduino : how to get started
Arduino : how to get startedArduino : how to get started
Arduino : how to get started동호 손
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino동호 손
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial동호 손
 

More from 동호 손 (6)

Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi
 
Arduino tutorial #1
Arduino tutorial #1Arduino tutorial #1
Arduino tutorial #1
 
Arduino : how to get started
Arduino : how to get startedArduino : how to get started
Arduino : how to get started
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 

Raspberry pi tutorial #2

  • 1. 1 Raspberry Pi Tutorial #2 - Measuring the light - Dong Ho Son POSTECH Pohang, Korea donghoson@postech.ac.kr
  • 2. 2 Measuring the light - Overview  Let’s use the sensor • Sensor : Analog  Digital − Analog : continuous − Digital : discrete • Photoresistor 3 pin (or light-dependent resistor, LDR) − A light-controlled variable resistor − The resistance increases/decreases according to the brightness of light • Let’s configure the circuit − The brightness of the LED is changed according to the brightness of the environment − If dark, the LED is turned on − If bright, the LED is turned off
  • 3. 3 Measuring the light - Overview  Measure the brightness of light and turn on/off the LED  Necessary Components • 1 x Raspberry Pi • 1 x Breadboard • 1 x red LED • 1 x Resistor • 1 x Photoresistor 3 pin • Jumper cables Anode Cathode GND OUT VCC
  • 4. 4 Measuring the light – Circuit configuration  Ground pin  the cathode of the LED  The anode of the LED  a ballast resistor  The ballast resistor  the pin GPIO 18  VCC of photoresistor  3.3V  OUT of photoresistor  the pin GPIO 17  GND of photoresistor  Ground pin Cathode Anode
  • 5. 5 Measuring the light - Python  Import RPi.GPIO as GPIO • Import Python GPIO module  GPIO.setmode(GPIO.BCM) • Use Broadcom chip number  GPIO.setup(17, GPIO.IN) • Select GPIO #17 as input pin • Measure the brightness using sensor  GPIO.setup(18, GPIO.OUT) • Select GPIO #18 as output pin • Turn on/off the LED
  • 6. 6 Measuring the light - Python  GPIO.input(17) • Return 0(bright) or 1(dark)  GPIO.output(18, GPIO.LOW) • Turn off the LED  GPIO.output(18, GPIO.HIGH) • Turn on the LED  time.sleep(1) • Delay for 1 second
  • 7. 7 Measuring the light - Result  If bright, the LED is turned off  If dark, the LED is turned on Cathode Anode