Stairs ledstrip with pir sensors keeps running, please help

vincentvega_nl:
I use the phone charger and a USB cable to power the arduino, not to the pin but to the USB port on the board, is that wrong?

That'll do just fine.

It seems you're using 5V LEDs, which of course need a separate power supply. That 5V supply can also be used to power the Arduino.

Because the ledstrip is quite long I got the 12v strip ( ws2815 ) and power supply, the charger is just for the arduino.

And it since all the LEDs work and all light up without flickering or something and the color wipe animation begins I thought it was wired correctly.

Is there anything you can think of what makes the animation repeating over and over? Even without the sensors connected?

Is there anything you can think of what makes the animation repeating over and over? Even without the sensors connected?

void setup() {
 
  pinMode(motionPin, INPUT_PULLUP);                                                                      //PIRs declared as inputs
  pinMode(motionPin2, INPUT_PULLUP);

So you pulled the wires and the input pins just stay HIGH?
Connect those pins to ground and see if the animation still runs.

When you change INPUT to INPUT_PULLUP you need to invert logic on pin tests.
if (senseMotion == LOW || senseMotion2 == LOW) {

Is there anything you can think of what makes the animation repeating over and over? Even without the sensors connected?

pinMode(motionPin, INPUT_PULLUP); 
pinMode(motionPin2, INPUT_PULLUP);

if (senseMotion == HIGH || senseMotion2 == HIGH) {

INPUT_PULLUP connects the pins internally to 5v across a large resistor. The pin will read HIGH unless the PIR sensor pulls it low.

Depending on the sensors and how they respond to motion, you might just be able to change the logic to LOW.

Otherwise, write a simple test sketch to understand when the sensors go HIGH and LOW and adjust the logic accordingly. You may also need to respond to a state change--that is when the sensors transition from LOW to HIGH or HIGH to LOW.

GoForSmoke:
When you change INPUT to INPUT_PULLUP you need to invert logic on pin tests.

That doesn't make sense, as the signal depends on the working of the sensor, not whether or not you have the pull-up enabled.

So I took my multimeter and placed it on the gnd of the arduino and pin 5 and 7 give about 2.5/ 3 volt, always, without the sensors connected.

Only those pins, so that's probably what's happening right?

So now what do I do?
I feel like we are getting somewere

With the sensors not connected, don't read those pins as INPUT_PULLUP keeps them HIGH.

Just set the variables senseMotion and senseMotion2 to zero (LOW).

Do you mean this?

int senseMotion = 0;
int senseMotion2 = 0;

It's already set to 0

Either don't read the pulled high sensor pin or zero the variables after the sensor read lines.

Just because you disconnected the sensors doesn't mean the pin can't read HIGH.

And how do i make that happen in de code?

2 PIR (Pyroelectric infrared) Sensors (HC-SR501

)

Have you tried

if (senseMotion == LOW || senseMotion2 == LOW) {

vincentvega_nl:
And how do i make that happen in de code?

Comment out the code that reads the sensors so it's easy to change back later.
Add two lines to set the sensor values to zero.

//    senseMotion = digitalRead (motionPin);      //set variables equal to what our sensors are reading (on or off)
//    senseMotion2 = digitalRead (motionPin2);
    senseMotion = 0;
    senseMotion2 = 0;

You REALLY should be learning enough code to read it -before- you go lifting Other People's Code.

Yes I know, this project is turning out more difficult than I expected.

Thank you, I'll try it when I get home

The project doesn't look particularly difficult to me, pretty simple even. Two inputs (the PIR sensors), one output (the stair lights), albeit with some complexity on the output.

It is more a case of trying to run before you can walk. You need to learn basic programming. Learn to read the sensors one by one. Then the combination of the two. After that do the stair lights - again in steps. Learn more as you go!

If you're stuck self-isolating and can kick off the dread of the unknown, you can lose a boring hour here and there and know more every time. Don't look at the top of the hill, just that section of trail to climb next.

Beyond that, you know you better than I do.

It works!

One of the sensors is flipping out a little but I probably need to adjust the delay and sensitivity. That will be fine.

Wvmarle, Goforsmoke, thank you very much. I've been on and off this project since Christmas, and was about to throw it in the dumpster. So I really appreciate you help.

I'll keep learning basic arduino code since I have a extra Uno board now so next time I have a idea I'll do the proper research before starting ; )

Don't forget: when buying parts, if you need one, buy 10. Chances are you will need them later or do something wrong and burn a part (also the cost of buying 1 or 10 is often not much different thanks to shipping). The "worst" of that for me was when I needed one capacitor... and I bought 600 (a kit with 20 pcs of 30 values).

Good luck with your next project :slight_smile:

@wvmarle Haha, ordering and receiving way more… Order 5 USB Micro to USB mini adapters and received 25...… Regarding shipping, and in Sweden, import taxes and fees, 10 USD, sure, buy a few extra at the same time.

You didn't realise they're sold in packs of 5?

I had the same when buying crystals... that were packs of 10...

Clearly not..... and it's not the first time. The ridiculously low prices on Ebay have made me think the sale is one unit.