In our previously published guides, we listed commonly used transistors with Arduino and How to Turn on LED with LDR. In that turning LED on, we needed no transistor. We Can Create an Arduino LDR Module With Transistor in Easy Way to Print Response as Either Zero or One. We will use a BC 547 as transistor, which is an NPN transistor. After testing this diagram on breadboard, you can make it permanent on any prototype board to make it a LDR Module.
Create an Arduino LDR Module With Transistor
For this project, we need :
- One 10K Ohm resistor
- Two 1K Ohm resistors
- One LDR
- Few Jumper Wires
- Breadboard
- Arduino UNO or similar board
We have drawn the circuit diagram using Fritzing in easy to understand way for the beginners :
---
In the circuit, we are supplying 5V to two 1 K Ohm resistors. One of those 1K Ohm resistor, one is connecting to collector pin of transistor. This is a current limiting resistor which will help the transistor to switch between ON and OFF states. The same pin of transistor is also connected to Arduino’s digital pin. Another 1K Ohm resistor is connected to one leg of LDR. It is a pull down resistor. Another leg of LDR is connected to base pin of transistor and 10K Ohm resistor. End of the 10K Ohm resistor is going to emitter of transistor and GND of Arduino. Current flowing through collector to emitter is directly proportional to the current applied at the base of the transistor.
This is the code to test :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | int ldr_pin = 2; void setup() { // serial communication t0 debug Serial.begin(9600); // collector pin of transistor pinMode(ldr_pin, INPUT); } void loop() { // read int light_ldr = digitalRead(ldr_pin); // 1 for Dark and 0 for Light Serial.println(light_ldr); // adjust looking at serial monitor delay(500); } |
After uploading the code, you can open the serial monitor of Arduino IDE. When there will be light, the response will be printed as 0. When there will be dark, the response will be printed as 1.
Obviously, you can connect the wire to A0 instead of Pin 2 and use this snippet with analogRead
function of Arduino to get values printed from 0 to 1023 :
1 2 3 4 5 6 7 8 9 10 11 12 | int sensorPin = A0; int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(sensorPin); Serial.println(sensorValue); delay(100); } |
Do you know that this circuit without Arduino board actually can switch on a LED on dark? If we put a LED between collector and emitter pin of transistor, power with 5V from battery source, without Arduino, that LED will light up on dark.
Tagged With transistor with ldr , LDR TRANSISTOR ARDUINO , ldr transistor , ldr sensor circuit arduino transistor , ldr module ditambah transistor ke arduino , ldr module code , LDR module , ldr meten met servo without library , How to build an LDR module , bc 547 module for arduino