I need help to do a Counting project using light Sensor (or whatever can count)

Hi,

I'm very new in Arduino (but I know programming well).
I got a project from my Boss that makes me to learn Arduino, and I started loving Arduino very much :slight_smile:

Let me explain my project:

I need to make a device that counts up to 840 objects in a box. So, to make it easier, I devide them to 14 tubes, each tube can contain 60 objects (I can't make it lesser because of the size limit).

So, each tube will have 60 ldr sensors (or any light sensor). Something like this

Then I made a circuit like this to test, my idea is putting 60 LDRs to ONE analog only because arduino has limited analog port, it looks like it works. But I don't know if it will work with 60 sensors?

I found that light condition is making a lot of noise and I need to create a LED strip along with the sensors to improve the result. However, I prefer binary result (0 or 1) returned from each sensor, how to make it work?

// pin assignments
 int LDR = 0;
 
 // initialize the serial port
 // and declare inputs and outputs
 void setup() {
   pinMode(LDR, INPUT);
   Serial.begin(9600);
 }
 
 // read from the analog input connected to the LDR
 // and print the value to the serial port.
 // the delay is only to avoid sending so much data
 // as to make it unreadable.
 void loop() {
   int v = analogRead(LDR);
   Serial.println(v);
   //checking data range to find maximum location
   switch(v){
     .......
   }

   delay(1000);
 }

Does it look nonsense? Or do you have any better solution for me? Or any suggestion where I can find a supplier to do it?

I've checked from internet and found this one

Where can I find a supplier who can use this type of sensor to make 60 sensors in one?

Thank you very much and apologize for my poor English and limit knowledge of arduino (I will try to learn and improve my skills)

Miller Nguyen

rongxike:
I found that light condition is making a lot of noise

I wonder if that would be reduced if you had another (separate) LDR that was reading the ambient light level as a "sort-of" calibration for the counting LDRs.

I suspect weighing the box may be simplest way to count its contents.

When the solution to a complex solution is more complexity I think it is time to stop and think.

...R

Robin2:
I wonder if that would be reduced if you had another (separate) LDR that was reading the ambient light level as a "sort-of" calibration for the counting LDRs.

I suspect weighing the box may be simplest way to count its contents.

When the solution to a complex solution is more complexity I think it is time to stop and think.

...R

Thanks a lot for your reply.

I did think of the Weight sensor, however, I couldn't find any weight sensor with that thickness and length (5mmx200mm) and can recognize at gram unit.

This is what i've done

When you connect the LDR in series or parallel, the total resistance will vary with the number of un/blocked resistors. Add an pull up resistor to form an voltage divider, and measure the analog voltage. Then the 14 sensor arrays (tubes) can be measured by an Arduino Mega, having 16 analog inputs.

But you may have problems with 60 combined LDR, so that you can only connect less resistors, to more analog inputs. Then analog multiplexers (4051) can help you out.

But I'd second the use of load cells instead, there should exists some of the required sensitivity. What's the weight of one of your objects?

Another idea: a weak spring (spring scale) at the bottom of each box, that lets pass more or less light under the objects, from one side to the other, measurable with one LDR.

One more: use multiple LED, one for each object position. Then toggle the LEDs in sequence until a single receiver (LDR) at the other side will see the light from the first unblocked position.

After a careful research from google and youtube, I decided to go with load cell. I've ordered 4 load cell 780g, phidghetbridge 4-input and 8/8/8 interface.

I will update my test here when I receive my items

Thank you very much for your guidance

DrDiettrich:
When you connect the LDR in series or parallel, the total resistance will vary with the number of un/blocked resistors. Add an pull up resistor to form an voltage divider, and measure the analog voltage. Then the 14 sensor arrays (tubes) can be measured by an Arduino Mega, having 16 analog inputs.

But you may have problems with 60 combined LDR, so that you can only connect less resistors, to more analog inputs. Then analog multiplexers (4051) can help you out.

But I'd second the use of load cells instead, there should exists some of the required sensitivity. What's the weight of one of your objects?

Another idea: a weak spring (spring scale) at the bottom of each box, that lets pass more or less light under the objects, from one side to the other, measurable with one LDR.

One more: use multiple LED, one for each object position. Then toggle the LEDs in sequence until a single receiver (LDR) at the other side will see the light from the first unblocked position.

Please let us know about what you are counting, size, material and weight for a start.

Weedpharma