without sensor, arduino detect some value in ext a

lo’,

I don’t understand, my arduino has a programm with IR sensor,
when it’s connected to usb alimentation, the values are detected, the led-indicator is lighting and switch off when no detection,
When it’s in ext alimentation, the led indicator is always lighting, without sensor, with sensor but without people in front…

I forget something but what???

this code

#define DETECT_MIN 128
#define DETECT_MAX 1024
#define SILENCE      500

int inputPinSensor;
int ledPin;
int val;
int byte0;
int byte1;
int byte2;
int byte3;
int byte4;
int byte5;
int byte6;
int byte7;

void setup() {
      val = -1;
      inputPinSensor = 2;
      ledPin = 13;
      byte0=0;
      byte1=1;
       byte2=2;
       byte3=3;
       byte4=4;
       byte5=5;
       byte6=6;
       byte7=7;

      pinMode(inputPinSensor, INPUT);
      pinMode(ledPin, OUTPUT);
      pinMode(byte0,OUTPUT);
      pinMode(byte1,OUTPUT);
      pinMode(byte2,OUTPUT);
      pinMode(byte3,OUTPUT);
      pinMode(byte4,OUTPUT);
      pinMode(byte5,OUTPUT);
      pinMode(byte6,OUTPUT);
      pinMode(byte7,OUTPUT);


      digitalWrite(byte0,HIGH);
      digitalWrite(byte1,HIGH);
      digitalWrite(byte2,HIGH);
      digitalWrite(byte3,HIGH);
      digitalWrite(byte4,HIGH);
      digitalWrite(byte5,HIGH);
      digitalWrite(byte6,HIGH);
      digitalWrite(byte7,HIGH);
      
}      

void loop() {
      val = analogRead(inputPinSensor);
      if (val >= DETECT_MIN && val <= DETECT_MAX) {
            digitalWrite(ledPin, HIGH);
            digitalWrite(byte0,LOW);
            digitalWritebyte0,HIGH);
            delay(SILENCE);
            digitalwrite(ledPin, LOW);
      }
}

[\code]

thanks for some help
because Because