So I put this all together with this code... and it worked great but now all of the sudden...
The lights go out....then come right back on.... constantly.....
What should I look for to fix this??
I literally have NO idea what happened... it was working great!!! I even used a different nano and wrote the code to that one... same result.... [even with NO pir sensors hooked up...still off and on behavior continues]
Thanks all!!
#include "FastLED.h"
#define LED_DATA_PIN 9
#define NUM_LEDS 250
CRGB leds[NUM_LEDS];
int onTime = 30*1000; // 30 seconds
int motion_sensor_right = 11;
int motion_sensor_front = 12;
int fadeTimeDiff = 40;
void setup() {
FastLED.addLeds<WS2811, LED_DATA_PIN, BRG>(leds, NUM_LEDS);
pinMode(motion_sensor_right, INPUT);
pinMode(motion_sensor_front, INPUT);
}
void loop() {
if (digitalRead(motion_sensor_right) == 1 || digitalRead(motion_sensor_front) == 1) {
fadeIn();
delay(onTime);
fadeOut();
}
}
void fadeIn() {
for (int led = 0; led < NUM_LEDS; led++) {
leds[led] = CRGB::White;
}
for (int b = 0; b < 20; b += 2) { // b = brightness level
FastLED.setBrightness(b);
FastLED.show();
delay(fadeTimeDiff);
}
}
void fadeOut() {
for (int led = 0; led < NUM_LEDS; led++) {
leds[led] = CRGB::White;
}
for (int b = 20; b > 0; b -= 2) { // b = brightness level
FastLED.setBrightness(b);
FastLED.show();
delay(fadeTimeDiff);
}
for (int led = 0; led < NUM_LEDS; led++) {
leds[led] = CRGB::Black;
}
FastLED.show();
}
Post an an annotated schematic showing how you have wired it. Include all connections, power, ground and power sources. Also note any wires more then 10" in length. Note: Frizzies are not schematics!
I hooked them back up and put them in a dark drawer where they couldn't possibly get triggered but still have the same behavior...off then back on .... like it's stuck in a loop....
Create a simple program without fastled which simply switches on the nano's built in led when a PIR is triggered. This will test the behaviour of the PIRs.
Variable onTime should be uint32_t, not int.
Don't know if it's related to your fault, but you're starving the Nano (assuming classic Nano v3).
V-in needs 6 to 6.5volt minimum for the regulator on the Nano to make a stable 5volt supply.
If you have a stable external 5volt (LED supply), then connect that directly to the 5volt pin.
The LED strip should also connect to D9 through a (~330 ohm) resistor, and the cap on the LED strip is missing. Plenty of examples for adding those two parts can be found on Google. Failing to add those parts could damage the LED strip.
Leo..