#define b1 2
#define b2 3
#define b3 4
#define RED 10
#define BLUE 8
#define GREEN 9
int swb, cr = 0, cg = 0, cb = 0, swr, swg;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(b1 , INPUT_PULLUP);
pinMode(b2 , INPUT_PULLUP);
pinMode(b3 , INPUT_PULLUP);
pinMode(RED, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(GREEN, OUTPUT);
Serial.println(" Click any buttons you want");
}
void loop() {
// put your main code here, to run repeatedly:
swb = digitalRead(b1);
swg = digitalRead(b2);
swr = digitalRead(b3);
if (swr == 0)
{
delay(250);
cr++;
Serial.print("Cr=");
Serial.println(cr);
if (cr % 2 == 1)
digitalWrite(RED, 1);
else
digitalWrite(RED, 0);
}
if (swb == 0)
{
delay(250);
cb++;
Serial.print("Cb=");
Serial.println(cb);
if (cb % 2 == 1)
digitalWrite(BLUE, 1);
else
digitalWrite(BLUE, 0);
}
if (swg == 0)
{
delay(250);
cg++;
Serial.print("Cg=");
Serial.println(cg);
if (cg % 2 == 1)
digitalWrite(GREEN, 1);
else
digitalWrite(GREEN, 0);
}
}