int blue = 10;
int green = 11;
int red = 9;
int pb = 3;
bool last_stat_pb = LOW;
bool curr_stat_pb = LOW;
bool led = HIGH;
bool debounce(bool last_status_pb){
bool curr_status_pb = digitalRead(pb);
if(last_status_pb != curr_status_pb){
delay(5);
curr_status_pb = digitalRead(pb);
}
return curr_status_pb;
}
void setup() {
// put your setup code here, to run once:
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
pinMode(pb, INPUT);
digitalWrite(pb, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
curr_stat_pb = debounce(last_stat_pb);
if(curr_stat_pb == LOW && last_stat_pb == HIGH){
led = !led;
digitalWrite(red, led);
digitalWrite(green, led);
digitalWrite(blue, led);
}
last_stat_pb = curr_stat_pb;
}