Anyone can suggest what command can i use if my reading from a sensor (assuming IR distance sensor includes cable (20cm-150cm) [GP2Y0A02YK] : ID 1031 : Adafruit Industries, Unique & fun DIY electronics and kits) produces a certain voltage, then it would convert it into a 1 count?
If your sensor is connected to analog pin 2,
it = 0;
int distVal = analogRead(2);
if(distVal > aCertainVoltage)
{
it = 1;
}