I wrote a little Sketch for an RGB LED. I use 4 Buttons, 1 to reset the values of the 3 colors. Compiling does not show any error, but after the Reset of the board all colors are full brightness.I triggered the reset interrupt even with wires, leaving the button out. But nothing happens.
This is the code:
int red=0;
int green=0;
int blue=0;
boolean changed=true;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(50, INPUT);
pinMode(48, INPUT);
pinMode(46, INPUT);
pinMode(44, INPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
attachInterrupt(95, resetto0, CHANGE);
attachInterrupt(48, incrred, CHANGE);
attachInterrupt(46, incrgreen, CHANGE);
attachInterrupt(44, incrblue, CHANGE);
}
void loop() {
while (1) {
Serial.write("START");
if ( changed=true)
{
analogWrite(7, 0);
analogWrite(6, 0);
analogWrite(5, 0);
changed=false;
}
Serial.write("WAIT");
}
// put your main code here, to run repeatedly:
}
void resetto0()
{
red=0;
green=0;
blue=0;
changed=true;
Serial.write('RESET');
delay(25);
}
void incrred()
{
red++;
changed=true;
Serial.write('RED');
delay(25);
}
void incrgreen()
{
green++;
changed=true;
Serial.write('GREEN');
delay(25);
}
void incrblue()
{
blue++;
changed=true;
Serial.write('BLUE');
delay(25);
}
Any idea?