I am facing a problem and cannot figure out the problem. The goal is to turn on the LEDs when movement has been detected. Functionally, the flow performs these steps:
- Initialize the pin of the PIR sensor
- Read the PIR sensor
- If the value is HIGH, turn on the LEDs, otherwise turn them off
When the microcontroller is powered by USB, everything works fine: the sensor detects movements and the LEDs are correctly on and off.
When I use a 9v battery, it doesn't work ...
I did a series of tests to try to locate the problem:
- Read the sensor but do not use the value, and turn the leds on and off: it works -> I suppose the 9v battery is providing enough power?
- Switch on only 1 LED instead of 24: does not change the situation
In attached the schematics and the source code: For convenience, I placed the normal behavior in loopNormal() and my tests in loopDebug().
I must be missing something on the electronic part, but I'm too newbie to figure out what...
Thanks for your help!
DarkLED-BugWithBattery.ino (1.22 KB)