Projects / PNP dark detector

PNP dark detector

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. Check the pinout

    Use the datasheet or the diode test.

  2. 327 lux

    Build the divider

    LDR from 9 V to the base, 10 kilohm and pot from base to ground.

  3. Wire the emitter

    Emitter to 9 V positive.

  4. 11.1 mA

    Wire the LED

    Collector, 1 kilohm, LED to ground.

  5. 11.1 mA

    Test in the light

    The LED should be off.

  6. 330 lux

    Cover the LDR

    The LED turns on gradually.

  7. Adjust the pot

    Move the switching point.

  8. 332 lux

    Measure the LDR

    Light and dark resistance with the meter.

In short

How do you build a PNP dark detector?

A PNP transistor and a light sensor turn an LED on in the dark with no microcontroller, and a knob sets the switching point. You need PNP Transistor 2N2907, LDR Photoresistor, Resistor 10 kΩ, Potentiometer 100 kΩ (linear), LED 5 mm red, Resistor 1 kΩ, 9 V battery, 9 V battery snap with DC jack, Digital multimeter and Breadboard 830 Tie Points. It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
10
See the electronics first. This build uses PNP high-side switch. Try a PNP high-side switch in the circuit builder and watch the voltages and currents before you wire it.

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
9 V battery positivePNP emitterThe emitter of a PNP goes to the positive rail
9 V battery positiveLDR leg 1Top of the light divider
LDR leg 2PNP baseDivider output is the base node
PNP base10 kilohm resistor, then the 100 kilohm pot (wiper joined to one end) to 9 V negativeBottom of the divider, 10 kilohm minimum
PNP collector1 kilohm resistor to red LED anode (long leg)Current limit for the LED
Red LED cathode (short leg)9 V battery negativeLoad returns to ground

Code

A bipolar transistor is a current-controlled switch, and a PNP is the mirror image of the more common NPN. Its emitter goes to the positive rail, and it turns on when current flows out of its base, which happens when the base is pulled about 0.65 volts below the emitter. Here a light-dependent resistor sits between the supply and the base, and a fixed resistor plus a pot sit between the base and ground. In bright light the LDR is only a few kilohms, so very little voltage appears across it and the transistor stays off. In the dark the LDR rises to hundreds of kilohms, the base is pulled down by the lower resistors, and the transistor turns on and lights the LED. Turning the pot changes how dark it must be, because the larger the lower resistance, the higher the LDR resistance at which the circuit starts to switch. Always keep the fixed 10 kilohm resistor in series with the pot, since otherwise a pot at zero would put an unlimited base current through the transistor. The LED turns on gradually, not suddenly, which is a useful lesson in why comparators and Schmitt triggers exist. Check the transistor pinout before wiring, because a backwards PNP simply will not work and may get warm.

Build notes (no code needed for this build)

Check the pinout first. A common 2N2907 or PN2907A in a TO-92 case is Emitter, Base, Collector, but versions differ. Use the diode test on the multimeter or the datasheet for your part.

How the circuit works
  A PNP transistor turns on when its base is about 0.65 V BELOW its emitter. The emitter is on the 9 V rail, so the base must fall to about 8.35 V.
  The LDR sits between the 9 V rail and the base. The fixed 10 kilohm plus the pot sit between the base and ground. Call that lower resistance Rb.
  In bright light the LDR is small, so the voltage across it is under 0.65 V and the transistor stays off.
  In the dark the LDR is large, the base is pulled down towards ground and the transistor turns on.

Switching point
  The transistor starts to conduct when the LDR resistance is about 0.078 x Rb.
  Rb = 10 kilohm (pot at 0)   : switches when the LDR is about 0.8 kilohm (very bright to dark only)
  Rb = 60 kilohm (pot half)   : switches when the LDR is about 4.7 kilohm
  Rb = 110 kilohm (pot full)  : switches when the LDR is about 8.6 kilohm (dim room)
Measure your own LDR with the meter in the light and the dark to see where the switch point falls.

Why the 10 kilohm is always in series with the pot: if the pot is turned to zero, the base would be tied to ground and base current would be limited only by the transistor, which can damage it.

LED current when on: (9 - 2.0 - 0.2) / 1 kilohm = about 7 mA, within the LED rating.

Expect a gradual turn-on: a transistor is not a comparator, so the LED fades up over a small range of light. To make it snap on, you would add a second transistor or use a comparator chip such as the LM393.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
LDR in room lightLED off
LDR covered by a fingerLED on, about 7 mA
Pot at minimum resistanceNeeds very dark to switch
Pot at maximum resistanceSwitches in a dim room
LED turn-onGradual, over a small range of light

If it does not work

LED never lights

Check the pinout, the LED direction and the pot is not at its lowest with a very bright room.

LED always on

The LDR may be disconnected or the pot is at maximum with a dim room.

LED dim even when covered

Check the 1 kilohm value and the battery voltage.

Transistor gets hot

Check the collector resistor is in series with the LED.

Switching point too sensitive

Raise the lower resistance with the pot.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the PNP dark detector?

PNP Transistor 2N2907, LDR Photoresistor, Resistor 10 kΩ, Potentiometer 100 kΩ (linear), LED 5 mm red, Resistor 1 kΩ, 9 V battery, 9 V battery snap with DC jack, Digital multimeter and Breadboard 830 Tie Points.

How long does the PNP dark detector take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the PNP dark detector works?

LDR in room light: LED off. LDR covered by a finger: LED on, about 7 mA. Pot at minimum resistance: Needs very dark to switch.

LED never lights: what should I check?

Check the pinout, the LED direction and the pot is not at its lowest with a very bright room.

LED always on: what should I check?

The LDR may be disconnected or the pot is at maximum with a dim room.

LED dim even when covered: what should I check?

Check the 1 kilohm value and the battery voltage.

Transistor gets hot: what should I check?

Check the collector resistor is in series with the LED.