Object counter « counting box »

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. https://www.youtube.com/watch?v=Z4tmelKKGfw 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,

Fritzing Sketch.jpg|3042x1569

It's a very nice looking drawing but, (sorry) for a circuit of more than a few connections it becomes very difficult for someone not familiar with the thing to decode what they're seeing. This is because with all the components out there, some with tens of pin connections, it's nearly impossible to tell just by looking how something is wired up. Most experienced people are used to looking at schematics where the parts' pins are named & numbered so you can see at a glance what's connected to what. Here's an example from Maxim's site:


This emphasizes the Maxim part but it illustrates the principle. A full schematic would include all connections, with pin names/numbers, for *all *components. Unfortunately this would also mean expanding signals grouped into a single line for brevity like the digit and segment lines in the drawing.

Even a hand-drawn schematic including the pin names/numbers is better in this case than a pictorial and would, IMHO, get more responses and allow people to see more exactly how you've made all the connections and so give an informed response.

Yes, it's more work but it would be a useful experience. Besides, you'll need a real drawing to work from and to have available for future reference. There are choices of drawing software but I use the free ExpressSCH.

max7219 schematic.PNG|717x410

Agreed, totally unreadable. Especially as the MAX7219 and display pinouts are not given. So can't tell whether the connections are correct or not.

No decoupling cap at the MAX7219. That's an issue.

Ahah, i guessed you would answer that it’s unreadable :-)

I’ll try to make a more readable one, following your advices.

Also, i’ll add the 10 uf electrolytic and 0.1uf(100n) ceramic capacitors, as it seems like it’s mandatory to have them.

Would that be ok ?