LDR Object Counter




Introduction: LDR Object Counter

About: I am an electrical engineer and an Arduino and electronics enthusiasts. I believe working with electricity should be fun as well as beneficial to engineers and the world at large. Twitter handle: @arduinohack…

I had several LDRs lying around in my room so i decided to do a simple project with one of them. I made an LDR object counter. By the way for those who do not know, LDR stands for light-dependent resistor. If you have never used it before, take a few minutes to learn how to connect and use it with an arduino. Moreover, your knowledge of voltage dividers will come in handy when working with the LDR.

Step 1: Controlling an LED

To get started i controlled an LED using analog input from the LDR.

The setup included:

· Light dependent resistor (LDR)

· 22k resistor

· Led

· Arduino uno

You can view the video here.

Step 2: Video

Step 3: LDR Counter

The LDR counter was a little bit complex than the led control setup. This is because i used a neopixel matrix to display the number of objects that had passed through.

The setup works on a simple principle. The LDR's resistance increases when there is no incident light shining on it. So, every time an object passes by and blocks light to the LDR we get a lower reading on the analog pin. Every time this happens the counter increases by one, just as shown in the video.

Step 4: Requirements


· 22k resistor

· Arduino uno

· WS2812b neopixel matrix

Step 5: Setup

The setup is as shown in the photo. You can learn how to connect the neopixel matrix to the arduino board here.

The rest of the setup is similar to the one shown here or the one for LED control using the LDR with the exception of the LED. The full tutorial, including the set up, and code can be found here.

Step 6: Video

Be the First to Share


    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    4 Discussions


    1 year ago

    I really liked your project but the link of the code you shared does not work. Can you please share it again?


    4 years ago

    Can you please provide the code ! The link is not working !


    5 years ago

    Hey bro can i use 16x2 lcd for this project


    Reply 5 years ago

    Yes, but you will have to change the led display code to LCD code and also include the LCD library.