Go Down

Topic: Object counter « counting box » (Read 6433 times) previous topic - next topic


Mar 15, 2019, 07:36 pm Last Edit: Mar 16, 2019, 10:51 am by Nagaro

I have as project at work to create a « counting box ».
People in my team are counting daily small pieces (5 cm x 2 cm x 1 cm), in plastic, 1 by 1. For them to make their life easier (and increase our accuracy), i would like to create a small box where they could throw the pieces inside, and it would count them.

On this box, i would like 5 electonic parts :
- a PIR motion sensor (as the parts a really small, i don't want to have a laser only taking in consideration 1 direction but more a surface)
- a display (big and simple), where it would be possible to count from 0 to 100 (no lore info is needed, therefore a lcd screen is not mandatory
- a button « reset » (to put back to counter to 0)
- a button + (to manually increase the counter of 1)
- a button - (to manually decrease the counter of 1)
I bought a Arduino nano, i think totally enough to perform the job.

I found a lot of videos taking about it in internet, but none of them are fulfilling my requirements. Like this one : https://youtu.be/WSDeNvYDZOw

Would anybody have information to help me ?
Thank you


Please Google pir sensor and study how they work.




Thank you for the answer.
I just figured out that pir sensors can only detect « warm » bodies. So i don't think it will detect my plastic bags. Is that right ?

If that's the case, which kind of sensor do you think i should use to detect those plastic bags ?

Again, i would like to cover a surface more than a single line. So to have a detector capable to check in 2 dimensions, and not only 1.

Or maybe there are some « tricks » that could do the job as well.

Thank you for your support


IR emitter and IR detector or Ultrasonic Sensor will do the job.


Mar 18, 2019, 09:13 am Last Edit: Mar 18, 2019, 09:23 am by neiklot
Ultrasonic Sensor will do the job.
Might be too slow, and miss some items.

I'd go with....

IR emitter and IR detector
... though.

Get one of these to test with; they come in different distances. You can test without an Arduino: just apply 5V and see if its onboard led blinks as the item drops past.

When it gets to coding, you'll need to go the state change detect route, else it will likely give multiple counts while the item's in front of the beam for a while as it passes..


Plastic piece? Plastic bag? What exactly do you have? Bags don't throw well, and you mention you're throwing them.

I was thinking of a bounce plate. Like used in seed counters. But it depends on what your plastic pieces really are, so do post some images!
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Apr 05, 2019, 10:48 pm Last Edit: Apr 05, 2019, 10:50 pm by Nagaro

Sorry for the long time without replying.
Attached 2 pictures to show which kind of items to count we are talking about.
They are plastic bags with jewellery items inside, in silver or gold. Therefore the accuracy needs to be perfect, as it's high value items (and not just screws or anything). The size of the bag can be 4x6 cm (like the small one o nthe picture), or 8x12 (like the big picture).

Would this "Pololu Carrier with Sharp GP2Y0D815Z0F Digital Distance Sensor 15cm" you propose detect those bags? If yes, as i'm leaving in Germany, do you know if i can get it somewhere in europe where i don't need to wait 1 month to receive it ? Or a similar component maybe ?
And if no, any other idea of cheap but reliable component i could use ?

Other question : for the display and the buttons, would you have references you rely on i could buy ? I don't want to buy anything, and then it breaks after 2 hours...

Thank you for the help again,


That seriously ups the ante.

IR: the bags may be transparent (probably are) to IR. So your bags may not be seen (all transparent passing in front of the sensor), or counted double (object & label as separate items) or triple (the necklace: two signals when the necklace passes, and a third for the label). You will have to try that out.

Speed: check the data sheet of the sensors for how quick they can react, and make sure your bags don't fall past the sensor too fast. And make sure that your bags fall in front of the sensor in the first place, in an orientation that allows them to be seen reliably.

You will anyway have to make sure there's enough time between the items, to be able to count properly. So the actual handling is going to be a major factor. Is it people throwing the bags one by one in the counting machine? Or do you want them to dump a box full of items in some hopper that then does the separation into single items and counting?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


The people will throw each bag one by one (not a full bag), so that's already a good point.

I understand that the IR might count double or triple the item, which need to be send in a way that the sensor recognize them.
But what about if i install 2 or multiple IR (to make a kind of grid). With the code making sure when 1 IR detects the item, it deactivate all other IR for a few milliseconds before they are all activated again ?


I wouldn't disable the sensors, just ignore the input from the others. If you know you're not going to get more than say one bag per second, you can safely ignore all other triggers for half a second before counting again.

The main thing is going to be the physical layout of the whole thing. You have to cover it in a sensor grid that's fine enough to not let the smallest bag pass undetected. That's why I'm still thinking you may be better off with a bounce plate - I think at least you should have a look at the option. A piezo disk or two and rigid plate is what's needed.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Apr 11, 2019, 11:18 am Last Edit: Apr 11, 2019, 11:24 am by Nagaro
You're right, ignoring the signal for a couple of milliseconds would make more sense :-)

If i understand it correctly, the bounce plate would count a item from the moment it touches it. Right ?
If i have in my box 50 or 60 pieces already, and i continue to launch some inside, would it still count it accuratly ?

I've ordered yesterday some push buttons, IR sensors and 7-sensors components with 3 digits (as we'll never count more than 999 pieces at once, but more than 99 yes).
Do you know where i can find which resistors i need to use ? And how to place them ?
I don't want to make any mistake and break the components from the 1st use.

For the arduino code, i'll check around if i find easy code. Otherwise, do you know where i could find some help ?

Thank you very much again for your help, and your quick responses always


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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


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 :-)
Then I'll need to figure out the electrical schema, and then the Arduino code. Still some steps to go.



Apr 12, 2019, 12:00 am Last Edit: Apr 12, 2019, 12:01 am by dougp
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.

I don't trust atoms.  They make up everything.

No private consultations undertaken!

Go Up