08-03-2019, 20:36
Witam,
borykam się z problemem jakim jest po podaniu zasilania do podświetlania schodów.
Po zmierzchu dochodzi dopiero prąd do całego układu i wtedy na stale zapalają się wszystkie światła,
do momentu gdy nie wejdę na czujnik i uruchomi się sekwencja i od tego momętu wszystko działa normalnie.
Próbowałem już komendy clear do TLC ale nie pomaga.
Zwracam się do was o pomoc co zrobić aby się nie uruchamiały samoczynnie.
Pozdrawiam
Oto kod jaki mam:
borykam się z problemem jakim jest po podaniu zasilania do podświetlania schodów.
Po zmierzchu dochodzi dopiero prąd do całego układu i wtedy na stale zapalają się wszystkie światła,
do momentu gdy nie wejdę na czujnik i uruchomi się sekwencja i od tego momętu wszystko działa normalnie.
Próbowałem już komendy clear do TLC ale nie pomaga.
Zwracam się do was o pomoc co zrobić aby się nie uruchamiały samoczynnie.
Pozdrawiam
Oto kod jaki mam:
Kod:
#include <Tlc5940.h>
const int downButtonPin = 6; // włącznik dolny
const int upButtonPin = 7; // włącznik górny
int downButtonState = 0; // status
int upButtonState = 0; //status
int ledCount = 16; //liczba aktywnych wyjść (światełek)
int brightness = 4095; //maksymalna jasność
int brightStep = 28; //krok przy rozjaśnianiu
int brightStep1 = 7; //krok przy ściemnianiu
int delayTime = 2; //szybkosc
int outs[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; //wyjścia do których podpinane są taśmy
void setup()
{
Tlc.init();
for (int diode=0; diode<ledCount; diode++)
pinMode(downButtonPin, INPUT);
digitalWrite(downButtonPin, LOW);
pinMode(upButtonPin, INPUT);
digitalWrite(upButtonPin, LOW);
for (int diode = 0; diode<ledCount;diode++) {
Tlc.set(outs[diode], brightness-outs[diode]);
}
Tlc.update();
}
void loop()
{
downButtonState = digitalRead(downButtonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (downButtonState == LOW) {
downButton();
// upButton();
}
upButtonState = digitalRead(upButtonPin);
if (upButtonState == LOW) {
upButton();
}
}
void downButton() {
for (int diode = 0; diode<ledCount;diode++) {
int bright = brightness;
do {
if (bright<0) {
bright = 0;
}
Tlc.set(outs[diode], bright);
Tlc.update();
delay(delayTime);
bright = bright - brightStep;
} while (bright>=0);
}
for (int diode = 0; diode<ledCount;diode++) {
int bright = 0;
while (bright<brightness) {
bright = bright + brightStep1;
if (bright>brightness) {
bright = brightness;
}
Tlc.set(outs[diode], bright);
Tlc.update();
delay(delayTime);
} ;
}
}
void upButton() {
for (int diode = ledCount-1; diode>=0;diode--) {
int bright = brightness;
do {
if (bright<0) {
bright = 0;
}
Tlc.set(outs[diode], bright);
Tlc.update();
delay(delayTime);
bright = bright - brightStep;
} while (bright>=0);
}
for (int diode = ledCount-1; diode>=0;diode--) {
int bright = 0;
while (bright<brightness) {
bright = bright + brightStep1;
if (bright>brightness) {
bright = brightness;
}
Tlc.set(outs[diode], bright);
Tlc.update();
delay(delayTime);
}
}
}