Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light Activated Switch Tutorial with LDR (Light Dependent Resistor and NPN transistor) #26

Open
seveibar opened this issue Oct 18, 2024 · 0 comments

Comments

@seveibar
Copy link
Contributor

The light-activated switch is a simple and practical circuit that uses a light-dependent resistor (LDR) and a transistor to control an output, such as turning on an LED or activating a relay based on ambient light levels. Let’s break down how this circuit works and its components in more depth:

Components:

  1. Light Dependent Resistor (LDR)

    • A special type of resistor whose resistance decreases when exposed to higher light intensity and increases in darkness. It’s used as the sensor in the circuit.
  2. NPN Transistor (e.g., 2N2222 or BC547)

    • Acts as a switch, controlling the current flow to the output device (such as an LED) based on the light level detected by the LDR. An NPN transistor requires a small current at its base to allow a larger current to flow between its collector and emitter.
  3. Resistor (typically 10kΩ or adjustable potentiometer)

    • Connected in series with the LDR to create a voltage divider. This resistor sets the threshold light level at which the transistor switches on or off.
  4. LED (or another output like a buzzer, motor, or relay)

    • The component that responds to the switching action of the transistor. When the transistor is activated, the LED turns on.
  5. Power Supply

    • A typical power supply (such as a 9V battery or 5V DC source) powers the circuit.

Circuit Design:

1. Voltage Divider (LDR + Resistor)

The LDR and a fixed resistor (or a variable resistor like a potentiometer) are connected in series to form a voltage divider. The voltage at the point between the LDR and the resistor is fed into the base of the NPN transistor. This voltage depends on the light intensity:

[
V_{\text{base}} = \frac{R_2}{R_1 + R_2} \times V_{\text{in}}
]

  • (R_1) is the resistance of the LDR (varies with light).
  • (R_2) is the fixed resistor (or potentiometer).
  • (V_{\text{in}}) is the supply voltage.

In bright light, the LDR’s resistance is low, and so the voltage at the base of the transistor will be lower. In darkness, the LDR’s resistance is higher, resulting in a higher base voltage.

2. Transistor Operation

  • Base Current: When the light level falls below a certain threshold, the voltage at the base of the transistor increases enough to turn it on (typically ~0.7V for an NPN transistor). This allows current to flow from the collector to the emitter, effectively turning on the output device (e.g., the LED).

  • Collector-Emitter Current: Once the transistor is switched on, the current flows through the collector-emitter path, allowing the connected device (e.g., LED) to operate. When the light level increases again, the base voltage falls, turning off the transistor, and the LED switches off.

3. Output

  • In this case, the output can be an LED, but you could also use a relay to control higher-power devices like a fan or motor. When the transistor is activated, the output device turns on. When the light level rises (or falls, depending on the circuit design), the transistor cuts off, and the output device turns off.

Working Explanation:

  1. High Light Conditions (Daylight)

    • The LDR’s resistance is low in bright light, and the voltage at the base of the transistor is not sufficient to turn it on.
    • As a result, the transistor remains in the OFF state, and no current flows through the collector-emitter junction. Hence, the output (e.g., the LED) is OFF.
  2. Low Light Conditions (Darkness)

    • In darkness, the LDR’s resistance increases significantly, which increases the voltage across the base of the transistor.
    • When the base-emitter voltage exceeds the transistor’s threshold (typically 0.7V for an NPN transistor), the transistor switches ON, allowing current to flow through the collector-emitter path, lighting up the LED or turning on another output device.

Adjusting Sensitivity:

  • The threshold light level at which the circuit switches can be adjusted by changing the value of the fixed resistor in the voltage divider. Using a potentiometer instead of a fixed resistor allows you to fine-tune the sensitivity of the circuit.
  • High resistance in the potentiometer results in a lower threshold (switches on in higher light), while low resistance results in a higher threshold (switches on in lower light).

Applications:

  1. Automatic Street Lights: Turns on lights when it gets dark.
  2. Garden Lighting: Lights up an area when the light level drops in the evening.
  3. Night Lamps: Automatically switches on a lamp when a room becomes dark.
  4. Solar Garden Lights: Detects low light and turns on the LEDs powered by a solar cell and battery.

Improvements and Modifications:

  1. Hysteresis: To avoid rapid switching between ON and OFF states (which could happen due to small light changes), you can introduce hysteresis by adding positive feedback or using a Schmitt trigger.

  2. Relay Control: Instead of powering a low-current device like an LED, you could connect the transistor’s output to a relay, allowing you to control high-power devices like mains-powered lamps, fans, or other appliances.

  3. Dual Control with PNP/NPN Transistors: You can design a circuit that has both light-activated and darkness-activated outputs by using a PNP transistor to handle high-light conditions and an NPN transistor to handle low-light conditions.

Schematic Diagram:

Power Supply (+) ----->---|
                          |
                       [ LDR ]
                          |
                          |------ Base (Transistor)
                       [ Resistor ]
                          |
Power Supply (-) ----->---|------- Emitter (Transistor)

Collector (Transistor) ----->---- LED ----> Ground

In this configuration:

  • The voltage across the LDR and resistor determines when the transistor turns on or off.
  • When the light level falls, the base voltage increases, turning on the transistor and lighting the LED.

This is a great introduction to transistor switching, sensors (like the LDR), and how basic electronic control systems work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant