3W LED module lights up twice without motion

I can't find a specific topic covering the following.. I get my 3W LED to light up with the activation of the motion sensor using code provided. What I don't understand is that the LED sometimes light up without ANY movement in front of the motion sensor? It runs smooth from the pc's USB power supply, but once I connect it to a powerbank (the culprit?) it lights up when it shouldn't..

This is dev77cmd's code I copied:

#define SENSOR_PIN 2
#define LED_PIN 3

void setup() {
  pinMode (LED_PIN, OUTPUT);
  pinMode (SENSOR_PIN, INPUT);

}

void loop() {
  int sensorValue = digitalRead (SENSOR_PIN);
  if (sensorValue == HIGH)
  {
    digitalWrite (LED_PIN, HIGH);
    delay(15000);
    digitalWrite (LED_PIN, LOW);
  }
  delay(1000);
}

How is the sensor wired up? Is the input floating when it is not HIGH?

It may be better if you had pinMode (SENSOR_PIN, INPUT_PULLUP) and then a sensor that made the line LOW when there was something sensed, but that depends on your sensor, which you have not described.

Thanks for the quick response. It's the PIR sensor, 2m-7m range (not the tiny variant). I think the issue was the powerbank. I even connected my two lithium batteries (18650 × 2) I'm using for the 1st time and there is no false alarm anymore. Only last week I learned how a bad powersupply (car battery) can screw with its systems.. the Arduino/sensor "world" seems to be very alike in that way. I should really do an Arduino course, I'm just not sure which one.. I'll check the forums on that topic.:thinking:

Looks like data out will be HIGH when active.

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