const int dpiupButton = 2;
const int dpidownButton = 3;
const int redPin = 4;
const int greenPin = 5;
const int bluePin = 6;
int dpiupState = 0;
int dpidownState = 0;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(dpiupButton, INPUT);
pinMode(dpidownButton, INPUT);
}
void setColor(int R, int G, int B)
{
analogWrite(redPin, R);
analogWrite(greenPin, G);
analogWrite(bluePin, B);
}
void standby () {
setColor(255, 0, 0); // Red
delay(1000);
setColor(0, 255, 0); // Green
delay(1000);
setColor(0, 0, 255); // Blue
delay(1000);
setColor(255, 255, 0); // Yellow
delay(1000);
setColor(80, 0, 80); // Magenta
delay(1000);
setColor(0, 255, 255); // Cyan
delay(1000);
}
void dpiup () {
setColor(255, 0, 0); // Red
delay(3000);
}
void loop()
{
dpiupState = digitalRead(dpiupButton);
dpiupState = digitalRead(dpidownButton);
if (dpiupState == HIGH) {
dpiup();
}
else {
standby();
}
}