I am using the circuit diagram below to turn ON/OFF the lights using Photo-resistor.

How can I use the Arduino to bypass the Photoresistor effect? Let say I want to turn ON the lights even though Photoresistor doesn't want to.

Take note the 12V source is required by the LED. Knowing that Arduino must work with max 5V.

enter image description here

3 Answers 3


You could replace the circuit with these:

  • Use one Arduino analog input to measure the light.

  • Use a Digital Out (Preferable PWM) to control the LED.

Then you can apply whatever logic you want.


simulate this circuit – Schematic created using CircuitLab

  • 2
    Among the other answers, this is the best, especially because: 1) The arduino can read the light intensity. 2) You can choose of having the LED either on or either off, or its intensity to be inversely proportional to the amount of light 3) you can easily add hysteresis by software 4) you can choose the threshold level, without having to change the pull-up resistor. One thing though: i would put R1 connected to the arduino GPIO and not to the gate, so that there won't be any divider. M1 must also be a 5V logic level MOSFET. Or you can use a BJT.
    – next-hack
    Sep 15, 2017 at 12:38
  • @next-hack R1 and R2 is NOT a voltage divider, its a common practice to pull down a MOSFET to ensure that it is in an normal OFF state and the value for R1 would be in 10K to 100k area. R2 is to protect Arduino from a faulty MOSFET that shortens the output and could be in 1K area.
    – MatsK
    Jul 24, 2021 at 13:05
  • I didn't write that R1 and R2's purpose is a divider, but the side effect is. To avoid this, you need to use R1 values at least an order of magnitude larger than R2, as you wrote. If you put R1 on the left (keeping R2), this constraint is removed. In this way, when the GPIO is uninitialized (i.e. during reset, in most - but not all - MCUs the GPIO ia at high impedance), M1 is kept in the off state by the series R1+R2. However, some MCUs might have some pins which even during reset have a -relatively- strong pull up, so you might want R1 low enough to force off state on M1.
    – next-hack
    Jul 25, 2021 at 19:12
  • @next-hack Now you are splitting hair strands! Over and out.
    – MatsK
    Jul 25, 2021 at 20:48

Be careful with the 12V, the Arduino can not handle 12V at its pins.

The input can be the photoresistor with a resistor to 5V (not to 12V). Use a analog input to measure the amount of light.

The output can be with a resistor to the base of the transistor.
This is an example: PighiXXX transistor
Any unused digital output can be used.
Why do you need 12V for the led ? Is it a special led ?


There are several ways to add Arduino control; the question doesn't provide quite enough information to say which is best.

One of the simplest methods is to use a diode to clamp the transistor's base voltage to at most 5 V, as shown in the following diagram.schematic with diode clamp added The voltage at the IO pin cannot exceed 5 V plus one diode drop.

With this circuit, setting the IO pin to be an input leaves the LED under photoresistor control. Setting the IO pin as a low output turns off Q1, and setting it as a high output turns on Q1. Note, R3 should limit the current drawn from the IO pin to at most about 25 mA, so 150 to 200 Ω may be suitable.

  • 1
    Yay! A fellow gschem user! ;)
    – Majenko
    Jul 15, 2017 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.