Infrared sensor giving the same values

Hello all,

For a school project we want to create a device using an infrared sensor that can sense te border of an archery target. Our idea was to put infrared lights around the target, and an infrared sensor on the bow. When moving the bow closer to the border of the target (and therefore closer to the infrared lights) a vibration motor should start vibrating faster, indicating that you're not aiming the right way.

For the sensor we thought we could use an HX1838 IR receiver (link down below). Using the analogRead function it would start giving us different values when an infrared light was detected. For some reason this doesn't work however, the value seems to change 1 time and then the same value as previously continues to print. Is it possible that this IR receiver only gets a single 'pulse' and therefore the value only changes ones? Somewhat like a remote?

I found a tutorial that somewhat shows what we want to do (link below), except that the infrared light doesn't reflect but points straight at the sensor. We want somewhat of the same outputs, but for us it seems to be constant. Do you think it will work with this infrared sensor? Personnaly I though there was no difference but I'm kind of a beginner on Arduinos.

Help would really be appreciated, we're in kind of in a tight schedule. Please let me know if anything is unclear. Thanks in advance.:slight_smile:

Thanks for responding and the remarks. Our code is pretty simple and actually looks a lot like the code in the video, the wires are also attached in the same way. That's why I think the problem is in the receiver itself, since that is like the only thing that is somewhat different. But I could be wrong of course

int mvm = 5; //micro vibration motor is connected with pin 5 which is the pwn pin.
int irsensor = A1; // irsensor is connected to pin ?

int analogValue = 0;

void setup() {
  // setup code:
  pinMode(mvm, OUTPUT);
  pinMode(irsensor, INPUT);
Serial.begin(9600);
}

void loop() {
  // read the analog value
  analogValue = analogRead(irsensor);
  
  // print the results to the serial monitor
  Serial.println("\nsensor = ");
  Serial.println(analogValue);

  // every time the loop runs it takes the value of the sensor and it changes the vibration of the mvm
  analogWrite(mvm, analogValue/4);

}