Hi all,
This is my sixth code, and the first one I can't seem to debug. I'd appreciate some feedback on this - when I run the code, there's no difference in the behaviors of the LEDs - they just fade together on one setting, or remain off on the other. headscratch
Thanks -
-FZ
int redPin = 11;
int bluePin = 6;
int redVal = 0;
int blueVal = 0;
int button = 7;
int rate = -1;
void setup (){
pinMode (redPin, OUTPUT);
pinMode (bluePin, OUTPUT);
pinMode(button, INPUT);
}
void loop (){
digitalRead (button);
if (digitalRead(button) ==HIGH){
if (redVal >= 255){
redVal = 0;
}
else{
redVal = redVal +1;
}
if (digitalRead (button) == HIGH){
blueVal = blueVal +1;
}
if (blueVal >= 255){
blueVal = 0;
}
analogWrite(redPin, redVal);
analogWrite(bluePin, blueVal);
delay(20);
digitalRead(button);
}
//** int rate = -1
if (digitalRead (button) == LOW){
if (redVal >= 255){
rate=-1;
{
if (redVal<=0){
rate = 1;
}
redVal = redVal + rate;
}
// digitalWrite(redPin, LOW);
//digitalWrite( bluePin, LOW);
//delay(20);
//digitalRead(button);
}
}
}