LED Self-control Light With Arduino

Introduction: LED Self-control Light With Arduino

I am a electrical student,like DIY and travel and reading.Recently I am interested in arduino pro...

This LED is controlled by Arduino.

According to the experiment you will find when the light is strong, the LED will off. When the light is weak the LED will on. Do you feel strange why this happen without light sensor? Now let me tell you the answer.

Check the connection diagram:

Step 1: Test the LED

Thanks PCBWay support, you can redeem Arduino and bread board in their gift shop.

As we know the LED will shine when powered on.

So will it generate voltage when we use illuminate LED? After experiment it is Yes, the LED also has photovoltaic effect. An ordinary white LED will generate generates tens of millivolts of voltage at 4.7M resistance if exposed to slightly strong light (For high-power LEDs, the voltage generated is even higher).

When the load is 4.7M, the measurement results of several LED photovoltaic effects in the room near the window:

1, white LED:

2, green LED:

3, red LED

Step 2: Code

Here, Arduino take advantage of the feature

of the LED for self-control. When there is no light, the LED doesn’t generate photovoltaic current or the current is small. And the circuit controls its connection. When exposed to light, the generated photovoltaic current is large and the circuit controls its extinguishing. The control sensitivity threshold is set by the program.

LED goes out during normal lighting

LED shine after block light

The code:

int temp=10;

void setup()




void loop()


pinMode( A0 , INPUT);

//delayMicroseconds( 10);

if (analogRead(A0) < temp )


pinMode( A0 , OUTPUT);

digitalWrite( A0 , HIGH );




else temp=10;




    • Metalworking Contest

      Metalworking Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Tiny Home Contest

      Tiny Home Contest