My code and wiring is correct but the IR sensor is not working

So I'm trying to do my first arduino project. Searched youtube for a guide the wiring is correct and this is the code

int ir=7;
// the ir is the infrared sensor
int x;

void setup()
{
Serial.begin(9600);
pinMode(7,INPUT);
}

void loop()
{
x=digitalRead(ir);
Serial.println(x);
delay(300);

}

Hello and welcome. Please take a few minutes and read How to get the best out of this forum . If you follow the recommendations there, you will make it possible for others to help you.

Despite your confidence, the wiring is the most likely suspect. Please post a hand drawn wiring diagram, with all connections, pins and parts clearly labeled.

Identify the Arduino, and also, post a link to the product page and/or data sheet of the IR sensor.

sorry one of my IR sensors is defective. it is working properly now. still thank you for the answers!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.