To make an object counter, We will be using Ardu-X, IR Sensor and LCD. The output signal of IR Sensor is in digital form. If an object is in front of it, it will give HIGH signal means it will give 1 else LOW means 0. Connection are shown as below and Code is also given.

Code explainations: In void setup, first we have to add initialize block for LCD, then integer in declared to store numbers and I named it counter. You can name it anything. The we have to define that we are using D2 as an Input. Now in forever, Condition is there. If digital read 2 is 0 means if object is there then it will give us 0 so if object is there then we have to set add +1 in a variable. then print counter and add some delay.