Quick Circuits #00: the Infrared Counter

Introduction: Quick Circuits #00: the Infrared Counter

About: I'm an electronic engineering student. I don't usually have much spare time but I like to work on random projects to keep myself entertained. I hope you like them!

I've been making random circuits for a lot of time, I have a vast amount of them, and it is because it usually takes me only one to a few hours to design and assemble one of them, any excuse is valid to start working on a new one, and so I denominate them "quick circuits".

I hope to be able to make a series of instructables regarding this unique, bizarre and sometimes completely useless circuits. This series will be probably characterized by lack of actual pictures during the test or assembly phases, but a lot of information on how they work and how to build them.

I'll start the series with this little circuit I called the counter.


  • 2x 3904 (I designed the circuit to work with this transistors, others might not work)
  • 1x 2N2222 (you can also use a 3904 again)
  • 7805 Regulator
  • 2x 100nF
  • Infrarred LED
  • Infrarred sensor (Two legs)
  • 2x 1M
  • 100k
  • 3x 10k
  • 1k
  • 150R 1W
  • 100R
  • Attiny85
  • Buzzer
  • Pushbutton

Step 1: What Does It Do?

This circuit has an infrarreed LED and sensor, it's function is to count how many times an object has passed in front of it. Since he At-tiny lacks of the necessary outputs to drive a display, the number decomposed and sent out with a buzzer, this is, the buzzer beeps according to the units (thousands, hundreds,...) making a pause between each number. This is certainly not the best way to do this, but it is what makes this kind of circuits unique. An Attiny2313 would've been a better choice, but I don't have any at the moment, if you want, you can replace the microcontroller and use the same analog part, which is quite effective, it can detect an object from 3 to 5 centimeters away, increasing its detection capabilities with white or reflective objects.

I originally designed this circuit because I'm going to try to get into the world of Tesla coils and I hope this little device can help me keep track of the windings of the secondary, I plan to stick a piece of paper to the tube while I spin it to do so.

Pressing the button to read the number doesn't affects the actual number, you can keep increasing it as long as the power is on.

It could also be used to count the units coming out of a production line, for example.

Step 2: How Does It Works?

To know how it works we must take a look at the schematic, when an object is in front of the unit, the infrared light bounces off, hitting the sensor, changing it's resistance and thus creating a signal. This signal is amplified by two 3904 transistors, the signal is amplified so much that at the end it just looks like a square wave, going from 0 to 5 volts, allowing an easier analog to digital communication.

As I was saying, when an object passes in front of the sensor, this goes from HIGH to LOW, allowing the microcontroller of choice to register the change.

I designed this circuit to be portable, and powered by a 9 volt battery, the circuit uses around 60mA, most of which pass though the IR diode. Considering a normal 9V battery has around 200mAh, the circuit would remain in operation for around 3 hours, so it is important to have a fresh battery or connect it to a wall wart if you are going to make it work for long periods of time. The IR resistor has the value of 150 Ohms since it's being powered by a 9 volt battery, if you would like to use it with a 12 volt wall wart I recommend changing the resistor by a 220 Ohm or a 330 Ohm, since the LED is a bit overpowered.

I've added a sch. file, so you can edit it in Eagle.

IMPORTANT: I designed this circuit to work with 3904 transistors, other transistors might not work due to differences in gain.

Step 3: The Program

The program is quite simple, it just counts the number of detected objects, beeping each time that occurs, the second part of the program is destined to separate the whole number into the units and send them through the speaker.

Step 4: Considerations:

To make the sensor I used two solid cables for the LED and other two for the sensor, then I twisted them together and connected them in the right way, by doing this I can easily orient them in front of the object or objects I want to count.

Step 5:

I hope it's been useful, maybe not as a whole, but as a circuit that can be chopped and implemented to other circuits.

Thanks for watching, please let me know if there are any mistakes or if you have some doubts about the circuit.

Be the First to Share


    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest



    7 years ago on Introduction


    You can reduce the circuit a bit. Look at the attached image :)


    Reply 7 years ago on Introduction

    It might be possible, I haven't tried to replicate your circuit, but it might also work fine, maybe losing some mm to some cm of detection range, but again, I'm not sure.

    This might be because the transistors I used are pretty old, so they've might not have as much gain as newer ones.


    Reply 7 years ago on Introduction

    It is more sensitive than your circuit as is => increased detection distance.

    If nothing else, do try reducing your R3 to, say, 10k for a higher sensitivity :)


    7 years ago on Introduction

    that's a pretty nifty little device :) and like you said could easily be combined to a larger system.


    O.K. I had to crank up the audio to hear the piezo, but it seems to work as advertised.

    These little bits and bobs can indeed be quite useful when bundled together with other circuitry to perform a task, nice project, thanks for sharing.


    Reply 7 years ago on Introduction

    I'm glad you liked it. If you want to increase the volume of the buzzer change the 100 Ohm resistor by a lower value, or even no resistor. Although for me it's loud enough, it might depend on the buzzer or piezo you're using though.

    I like to find circuits that aren't common at all, specially if they're analogic, I thought other people might enjoy rare circuits like this one.