Object counter « counting box »

A bounce plate would be mounted at the top of the box, so the item is falling first against that plate, then slides into the box.

Which resistors (if any, and capacitors for that matter) to use depends on the exact components you have.

For code, lots of examples out there for all kinds of components, do a Google search of your part number with “Arduino library” and good chance you’ll find some. There’s definitely code out there for all kinds of 7-segment displays and other kids of displays, for break beam sensors, for push buttons, bounce plates (aka “knock sensor”, see also this recent post & thread), etc.

Thanks for the description from the bounce plate. It changes the way i was seeing this counting box, but why not ;-)

I checked the link, and the video from the guy : basically i want to do the same principle, not with nerf but with jewelry :-)

I’ll have a deeper look, and see how it inspires me. I’ll buy already now a piezo vibration sensor like in the link, that i can try both option (IR or this one).

Now i need to receive it, and make some tests. I guess i’ll still need some help in a few days :-)


I’ve tried to make some small schema of the 2 possibilities for this counting box :

Schema 1 : with IR sensors

Schema 2 : with Bounce Plate

To make sure we are on the same level of understanding, and also that we go to the right direction, do you confirm that these schema are correct ?

If yes, we’ll have our physical prototypes :slight_smile:
Then I’ll need to figure out the electrical schema, and then the Arduino code. Still some steps to go.


Or, combine the two into a chute with an IR sensor. Mount the IR as low to the sliding surface as practicable. As the package slides it breaks the IR beam.


And add a capacitive sensor to the chute.

The IR sensors pictured are proximity sensors ,not break beam sensors. They work basically with opposite principles: break beam reacts to the absence of a beam because it's blocked by an object that's in the way; the proximity sensor reacts to the presence of IR light as it's reflected by an object in front of the sensor.

With those bags I think the first will work better: if the beam is reflected away, the proximity sensor will still not see it. Experimentation is needed, for sure.

Thanks for all these replies.

Now i have 3 questions for you :

  • what is the maximum distance that a ir proximity sensor can detect ?

  • can i mount both ir sensors together to build a break beam sensor (like the picture from dougp) ?

  • what is the added value to have a capacitor ?

Nagaro: - can i mount both ir sensors together to build a break beam sensor (like the picture from dougp) ?

That exact configuration probably will not work. You need to know whether the sensors are modulated. If they are, each sensor is looking for its own light beam and others will be out of sync. You could try a corner cube reflector and a single sensor to make a retro-reflective sensor but I believe you'd have more success - and less fuss - using something made for the purpose. You might have to do some level translation but the sensor will be reliable.

Don't forget, you have to come up with a way to mount whatever you decide on. Commercial offerings are amenable to a wide variety of mounting options.

Some additional reading material.

Nagaro: - what is the maximum distance that a ir proximity sensor can detect ?

Depending on the actual sensor up to a few meters. The one pictured, 10-20 cm or so, but it depends highly on the object, the incident angle and the level of ambient IR.

  • can i mount both ir sensors together to build a break beam sensor (like the picture from dougp) ?

A proximity sensor looks for the presence of an IR signal, a break beam sensor for the absence. If you would place two proximity sensors opposite one another they would not give any signal: when there's no object presence they see the transmitted IR of the opposite emitter, when there's an object they see the reflected IR of their own.

If you want to go the break beam route, get a break beam sensor.

  • what is the added value to have a capacitor ?

Depends on where (both from an electrical and physical standpoint) exactly in your circuit you plan to add one, what value, and maybe even what type of capacitor it is.

Ok, thank you.

I think i have enough info now to start building the project, and come back with a feedback and probably more questions :-)

Good luck! Hope to hear about the result.

My (mostly tongue-in-cheek) suggestion was to add a [u]capacitive[/u] [u]sensor[/u], not a capacitor. That would add a third sensor (probably) capable of sensing a plastic bag sliding by it. While you're at it, you could also try a laser proximity sensor. :)

All types of sensors may be confounded by two or more bags hitting nearly at the same time or sliding down the ramp together. Unless you can somehow guarantee that the bags will be separated by a "large enough" gap, your software will have to be capable of distinguishing between sensor data for one bag and multiple bags.

Yes, you’re right, a capacitive sensor might also work. The good thing is that all your suggestions gave me several potential solutions. I’ll start from mine (proximity sensors), and move to other ones if this one is not good enough.

For the time gap, as it will be launched by people using this box, they are anyway limited physically to a certain speed. And i guess this speed is lower higher than what the arduino can process. But this will be part of the test :-)

See you soon, for more concrete news :-)

A capacitive sensor will NOT detect a plastic bag passing by. Non-conductive materials are generally not detectable by such as sensor.

It may however detect the metal bits in the jewellery, depending on how much metal is in there and how sensitive it is. It also requires a capacitor that is designed to detect proximity, not touch.

wvmarle: A capacitive sensor will NOT detect a plastic bag passing by. Non-conductive materials are generally not detectable by such as sensor.


Capacitive sensors are used for non-contact detection of metallic objects & nonmetallic objects (liquid, plastic, wooden materials and so on).


Of course plastic does affect the electric fields. A little. If there's enough plastic. Covalent bonds in the plastic will help a lot. Thin polyethylene bags? Won't work.


I’ve started to build the circuit, and i’m facing the 1st issues i didn’t think about.
With the 7-segment with 3 digits, i’m using 11 pins on the arduino. Then with the 3 buttons (reset, +1, -1), and the ir sensors, it’s minimum 4 pins additionnal (and more if i use more IR sensors…). But the arduino only has 12 pins available.
I was checking on the internet, and i found a way to reduce the amount of pins used for the 7-segments from 11 to 7 pins, using a 7447.

But it would still be ready sharp for amounts of pins.

  • is the 7447 solution good, or is there a most recent way to do it, or easier or cheaper ?

  • is there a way to reduce even more the amount of pins needed, that they all fit on the arduino without any restrictions ?

For information, i’ll be using an Arduino Nano (i don’t have any other), but i guess it will be enough for this.

Thank you,

The MAX7219 display driver is mentioned often here. It's a serial interface requiring only three Arduino I/O pins.

Sounds great. I’ve checked on google, and found a tutorial on how to configure it (plaisirarduino.fr or https://thecustomizewindows.com/2017/11/arduino-max-7219-cng-basic-circuit-led-7-segment-displays/) I just bought on ebay the MAX7219CNG.

I’ll use a 10kOhm resistor, but not yet the 2 capacitors proposed (it seems like it’s only to have a more stable signal, so it will be in phase 2 for all improvements :-) )

Also : i had to buy a new 3-digits 7-segment, as mine was Anode and it seems like the MAX7219CNG only accepts Cathode. Too bad :-(

I’ll try to build the circuit on Fritzing, to document all of this, and also start checking the Arduino code.


Attached the Fritzing schematic from this project.
I’ve tried to make it as easy to read as possible.

Can somebody validate it, or tell me what to change/improve ?

Thank you,