#define PINRED A0
#define PINGREEN A1
#define PINBLUE A2
#define PINNEXT 11
#define PINSET 12
#include <LiquidCrystal.h>
LiquidCrystal lcd(9,8,5,4,3,2);
unsigned short int aC = 0;
bool test = true;
bool test2 = true;
bool change = false;
void setup()
{
 lcd.begin(16,2);
 lcd.print("Set color:");
 pinMode(PINNEXT, INPUT);
 digitalWrite(PINNEXT, HIGH);
 pinMode(PINSET, INPUT);
 digitalWrite(PINSET, HIGH);
 digitalWrite(PINRED, HIGH);
 digitalWrite(PINGREEN, HIGH);
 digitalWrite(PINBLUE, HIGH);
 pinMode(PINRED, OUTPUT);
 pinMode(PINGREEN, OUTPUT);
 pinMode(PINBLUE, OUTPUT);
}
void loop()
{
 if(digitalRead(PINNEXT) == LOW && test == true)
 {
 aC++;
 if(aC == 6)
 aC = 0;
 lcd.setCursor(0,1);
 switch(aC)
 {
 case 0:
 lcd.print("white ");
 break;
 case 1:
 lcd.print("red ");
 break;
 case 2:
 lcd.print("green ");
 break;
 case 3:
 lcd.print("blue ");
 break;
 case 4:
 lcd.print("yellow");
 break;
 case 5:
 lcd.print("purple");
 break;
 default:
 break;
 }
 test = false;
 }
 else if(digitalRead(PINNEXT) == HIGH && test == false)
 {
 test = true;
 }
 if(digitalRead(PINSET) == LOW && test2 == true)
 {
 change = true;
 test2 = false;
 }
 else if(digitalRead(PINSET) == HIGH && test2 == false)
 {
 test2 = true;
 }
 if(change == true)
 {
 change = false;
 if(aC == 0) // biela
 {
 digitalWrite(PINRED, LOW);
 digitalWrite(PINGREEN, LOW);
 digitalWrite(PINBLUE, LOW);
 }
 else if(aC == 1) // cervena
 {
 digitalWrite(PINRED, LOW);
 digitalWrite(PINGREEN, HIGH);
 digitalWrite(PINBLUE, HIGH);
 }
 else if(aC == 2) // zelena
 {
 digitalWrite(PINRED, HIGH);
 digitalWrite(PINGREEN, LOW);
 digitalWrite(PINBLUE, HIGH);
 }
 else if(aC == 3) // modra
 {
 digitalWrite(PINRED, HIGH);
 digitalWrite(PINGREEN, HIGH);
 digitalWrite(PINBLUE, LOW);
 }
 else if(aC == 4) // zlta
 {
 digitalWrite(PINRED, HIGH);
 digitalWrite(PINGREEN, LOW);
 digitalWrite(PINBLUE, LOW);
 }
 else if(aC == 5) // fialova
 {
 digitalWrite(PINRED, LOW);
 digitalWrite(PINGREEN, HIGH);
 digitalWrite(PINBLUE, LOW);
 }
 }
}