
Reading a Photoresistor — SIK Circuit 6
ការណែនាំ
Parts & Introduction
Parts & Introduction
A photoresistor (or LDR — Light Dependent Resistor) changes resistance based on light levels. Combined with a fixed resistor, it forms a voltage divider that the Arduino can read as an analog value. You'll use this to control LED brightness automatically.
Parts Needed
- 1x Arduino Uno + USB cable
- 1x Breadboard
- 1x Photoresistor
- 1x LED (any color)
- 1x 330Ω Resistor
- 1x 10KΩ Resistor (for voltage divider)
- 6x Jumper Wires
សម្ភារៈសម្រាប់ជំហាននេះ៖
SparkFun Inventor's Kit - V3.21 ឈុតឧបករណ៍ដែលត្រូវការ៖
Computer with Arduino IDEHardware Hookup
Hardware Hookup
Wiring Instructions
- Connect one side of the photoresistor to 5V.
- Connect the other side to Analog Pin A0.
- Connect a 10K resistor from Analog Pin A0 to GND (this completes the voltage divider).
- Connect the LED positive leg to Digital Pin 9 (PWM-capable).
- Connect the LED negative leg through a 330Ω resistor to GND.
The voltage divider produces a voltage proportional to light level, which the Arduino reads as 0-1023.
សម្ភារៈសម្រាប់ជំហាននេះ៖
Breadboard1 ដុំ
Jumper Wires5 ដុំArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
សម្ភារៈសម្រាប់ជំហាននេះ៖
Arduino Uno R31 ដុំឧបករណ៍ដែលត្រូវការ៖
Computer with Arduino IDETest & Experiment
Test & Experiment
What You Should See
The LED brightness changes based on ambient light. Cover the photoresistor to dim or brighten the LED (depending on orientation).
Troubleshooting
- LED stays dark: Check LED polarity. Also verify the photoresistor is in the circuit correctly.
- Not responding to light: The photoresistor spacing is non-standard — make sure both legs are making good contact.
- Subtle changes: Try using a flashlight or covering the sensor completely for more dramatic results.
Experiments to Try
- Uncomment
autoTune()to let the Arduino automatically calibrate to your lighting conditions. - Use the sensor to trigger actions at specific light thresholds (e.g., turn on a "night light" when dark).
សម្ភារៈ
8- SparkFun Inventor's Kit - V3.2កម្រៃ 10%1 ឈុត$108.84
- ចាប់ពី$9.76
- ចាប់ពី$4.27
- ចាប់ពី$27.80
- 1 ដុំកន្លែងទុក
- 1 ដុំកន្លែងទុក
- ចាប់ពី$1.22
ឧបករណ៍ចាំបាច់
1- កន្លែងទុក
CC0 សាធារណៈ
ប្លង់នេះត្រូវបានចេញផ្សាយក្រោម CC0។ អ្នកមានសិទ្ធិចម្លង កែប្រែ ចែកចាយ និងប្រើប្រាស់ដោយមិនចាំបាច់សុំអនុញ្ញាត។
គាំទ្រអ្នកបង្កើតដោយទិញផលិតផលតាមរយៈប្លង់របស់ពួកគេ ដែលពួកគេទទួលបាន កម្រៃជើងសារអ្នកបង្កើត កំណត់ដោយអ្នកលក់ ឬបង្កើតកំណែថ្មីនៃប្លង់នេះ ហើយបញ្ចូលជាការតភ្ជាប់ក្នុងប្លង់របស់អ្នកដើម្បីចែករំលែកចំណូល។