Grove IR distance Interruptor v1.2 not changing state

Hi,

I have a grove IR distance interrupter and I can’t get it to change states.

I’m using arduino uno r3.

I tried a couple different tutorials…what am I missing?
(Grove IR Distance Interrupter - Arduino : 3 Steps - Instructables)

Thanks very much for any assistance.

Connections:
VCC to 5V
GND to GND
SIG to terminal 2 (also tried 4 to be sure it wasn’t the terminal)

void setup() {
Serial.begin(9600);
pinMode(2,INPUT);
}
void loop() {
while(1) {
delay(500);
if(digitalRead(2)==LOW) {
Serial.println(“Something in range”);
}
else {
Serial.println(“Nothing in range”);
}
}

}

1 Like

Hello !
I have a similar issue but with more unstability: depending on some external factor I can’t figure out, the IR distance interruptor triggers for ever or works fine.

I mean: my circuit is a duino nano with some devices attached and the IR DI1.2. Sometimes when I power on the circuit, everything is fine. IRDI works as expected, detecting when my hand pass in front of it.
But a major amount of time, when I power it on, it will stay “on” with the led turned on, and won’t changed its state whatever is in front of it (generally “nothing”).

I supposed it was a cable issue but changing the cable did not do anything. I also changed the board, the MCU, the IRDI… nothing helps. Either I did something wrong, either the board has some settings I can’t understand. The last option is that all my boards are defective, but that is improbable. :slight_smile: