0

I need to use the IR flying-fish sensor as an essential part of my school project and I need it to check when there is a reflective tape over it. I built a circuit for it and programmed it accordingly, allowing it to compile. The green LED lights up but the IR sensor never receives anything.

This is my code:

const int ProxSensor=2;

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
  //Pin 2 is connected to the output of proximity sensor
  pinMode(ProxSensor,INPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.println(digitalRead(ProxSensor));
  if(digitalRead(ProxSensor)==0)      //Check the sensor output
  {
    digitalWrite(13, HIGH);   // set the LED on
    Serial.println("high");
  }
  else
  {
    digitalWrite(13, LOW);    // set the LED off
    Serial.println("low");
  }
  delay(100);              // wait for a second
}

How can I fix this to make it work?

Itay Lador
  • 313
  • 1
  • 10

0 Answers0