Hello everybody! My English is bad. Excuse me, please!
I am trying to deal with the interruption in the LED driver Tlc5940. Interrupting lights all at once with a given brightness LEDs.
My problem: after the "removal" interrupt the cycle continues once artifacts. Rather than simply continue with the place, when the interrupt occurs even running light across all LEDs. Help me please!
#include "Tlc5940.h"
int Leds = 8;
const int maxLight = 4095;
int delPWM = 10;
int stepPWM, stepPWMP;
byte intPin = 0;
void setup()
{
attachInterrupt(intPin,pause,LOW);
Tlc.init();
}
void pause() {
for (int i = 0; i <= Leds-1; i++)
{
Tlc.set(i, maxLight);
}
Tlc.update();
}
void loop()
{
for (int i=Leds-1; i>=0; i--) {
stepPWMP=1;
for (int j=0; j<=maxLight; j=j+stepPWMP) {
Tlc.set(i,j);
Tlc.update();
delay(delPWM);
stepPWMP+=2;
}
}
for (int i=Leds-1; i>=0; i--)
{
stepPWM=stepPWMP;
for (int j=maxLight; j>=0; j=j-stepPWM)
{
Tlc.set(i,j);
Tlc.update();
delay(delPWM);
stepPWM-=2;
}
}
}
Interrupt generates pressing the button. But since I do not have right now with fixing button, I use a wire, dropping it on the "ground". So I chose the interrupt level is low. When an interrupt occurs, the LEDs light up all at once. But when the interruption is over (the button is released), should continue the cycle. But now there is still a running light across all LEDs. I realized that it starts when I'm working with the PWM . Without PWM at full brightness it is not.
What? Pressing a switch can generate an interrupt. An interrupt can not press a switch.
But since I do not have right now with fixing button, I use a wire, dropping it on the "ground".
But, you don't have the internal pullup resistor enabled, so you have a floating pin. No guarantees what will happen under those circumstances.
You need to enable the pullup resistor, AND use CHANGE as the type. In the ISR, YOU determine what the change was, and deal with the change, OR you use RISING or FALLING. LOW is NOT the appropriate type.