Hello .Still pretty new to all of this but I am learning Question of the day is this .
when running the following sketch I can activate my original sketch by shading or covering the LDR.
The sketch starts . When I uncover the LDR the sketch stops but one lone LED remains lit
Haven't figured that part out yet .
For what it's worth I eventually wish to use a timer so that the sketch only runs for lets say 4 hours and then stops until triggered the next evening
PS Hope I posted the code proper this time
#include "Adafruit_TLC5947.h"
// How many boards do you have chained?
#define NUM_TLC5947 1
#define data 4
#define clock 5
#define latch 6
#define oe -1 // set to -1 to not use the enable pin (its optional)
#define BRIGHT 4095
#define PRETTY_BRIGHT 700
#define DIM 100
#define OFF 0
#define NUM_LEDS 20
#define Threshold_light 400
#define Threshold_dark 200
int LDRpin(A0);
int LDRValue = 0;
Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5947, clock, data, latch);
void setup() {
Serial.begin(9600);
LDRValue = analogRead(LDRpin);
pinMode(LDRpin, INPUT);
Serial.println("TLC5947 test");
tlc.begin();
if (oe >= 0) {
pinMode(oe, OUTPUT);
digitalWrite(oe, LOW);
}
}
void loop() {
LDRValue = analogRead(LDRpin);
Serial.println(LDRValue);
delay(2);
if (LDRValue <= 200) {
int i;
uint16_t led_value;
for (int i = 0; i < NUM_LEDS; i++) {
tlc.setPWM(i, BRIGHT);
tlc.setPWM((i + NUM_LEDS - 3) % NUM_LEDS, 0);
tlc.setPWM((i + NUM_LEDS - 2) % NUM_LEDS, DIM);
tlc.setPWM((i + NUM_LEDS - 1) % NUM_LEDS, PRETTY_BRIGHT);
tlc.setPWM((i + NUM_LEDS + 1) % NUM_LEDS, PRETTY_BRIGHT);
tlc.setPWM((i + NUM_LEDS + 2) % NUM_LEDS, DIM);
tlc.setPWM((i + NUM_LEDS + 3) % NUM_LEDS, 0);
tlc.write();
delay(100);
}
} else {
(LDRValue >= Threshold_light);
{
void stop();
}
}
}
The final result is no different . when sensing daylight the LEDS ( which blink in a sequential pattern around a disc ) all stop except one LED stays lit.. Actually it may be 3 . ONE BRIGHT, ONE PRETTY BRIGHT and ONE DIM They're very close together in a white PLA ring which doesn't do much to block light from the LED beside it
I was trying to find something like clear all LEDS if sensing daylight but I'm pretty new to this .
I also tried ( but only once) to install the universal timer library, wondering if a timer would stop all the lights .
Haven't got the timer 100% figured out yet . Got frustrated and came here hoping someone could solve in 5 mins what I've been at for a couple of days
I will try this for a much shorter tie frame of a few minutes to see if t works .
Question will this still allow everything to reset and start again the next night?
I like the sound of this and will try it since the timer function is the eventual desired plan.
This is for a battery operated and solar charged outdoor project Thus the reason for a timer to not run down the battery Summer use only since snow would not be good for this but I'd love to get this part working right soon and do my build thru the winter
Since I've never written this kind of code or much of anything it'll probably take me hours ...lol