This project provides an automated solution for counting items passing through a conveyor belt using an Arduino Uno and an Infrared (IR) distance sensor. The system is designed for real-time monitoring, using a Serial Monitor for data output and a physical reset button to clear the count.
Connect the components as follows in TinkerCAD:
| Component | Pin | Arduino Pin | Purpose |
|---|---|---|---|
| IR Sensor | VCC | 5V | Power Supply |
| IR Sensor | GND | GND | Ground |
| IR Sensor | Signal (OUT) | A1 | Analog Input |
| Reset Button | Terminal 1a | Digital 7 | Reset Trigger |
| Reset Button | Terminal 2a | GND | Ground |
Sensing: The IR sensor emits infrared light. When an object passes, the light reflects back, and the sensor sends an analog voltage to pin A1.
Detection Logic: The code monitors this voltage. When the value exceeds 500, the Arduino recognizes an object is present.
State Management: Once an item is counted, the system sets a "flag" (objectDetected = true). It will not count again until the object has completely cleared the sensor (value drops below 450). This prevents a single item from being counted multiple times.
Reporting: Every time a new item is validated, the updated total is printed to the Serial Monitor.
Reset: Pressing the button pulls Pin 7 to Ground (LOW), which triggers the code to reset the count variable to zero.
Assembly: Wire the components as described in the table above.
Code: Copy and paste the Arduino code (below) into the TinkerCAD code editor.
Simulation: Press Start Simulation.
Monitor: Open the Serial Monitor at the bottom of the code screen.
Test: Click on the IR Sensor in the workspace. Drag the green "ball" toward the sensor to simulate an item passing. You will see the count increase on your screen.
Reset: Click the pushbutton to clear the data.