analogsensor input don't work in ext alimentation


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;

      pinMode(inputPinSensor, INPUT);
      pinMode(ledPin, OUTPUT);


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


thanks for some help
because Because

This is wrong: digitalWritebyte0,HIGH); but this shouldn't even compile. I guess that you mean power supply with alimentation? Didn't you forget the jumper for the external power supply?