#include <LiquidCrystal.h>
String m []={"Off ", "White ", "Red ", "Green ", "Blue ", "Yellow ", "Purpule", "Cyan "};
LiquidCrystal lcd(13, 12, 7,6,5,4);
int x = -1;
bool y = true;
bool z = true;
bool a = true;
void setup() {
lcd.begin(16,2);
lcd.print(" Colours:");
pinMode(9, INPUT);
pinMode(8, INPUT);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
pinMode(10, INPUT);
digitalWrite(10, HIGH);
pinMode(1, OUTPUT);//Blue
digitalWrite(1, HIGH);
pinMode(2, OUTPUT);//Green
digitalWrite(2, HIGH);
pinMode(3, OUTPUT);//Red
digitalWrite(3, HIGH);
}
void loop() {
if(digitalRead(9)==LOW && y==true ){
y=false;
x++;
if(x==8)x=7;
lcd.setCursor(0, 1);
lcd.print(m[x]);
}
else if(digitalRead(9)==HIGH && y==false){
y= true;}
if(digitalRead(8)==LOW && z==true ){
z=false;
x--;
if(x==-1)x=0;
lcd.setCursor(0, 1);
lcd.print(m[x]);
}
else if(digitalRead(8)==HIGH && z==false){
z= true;
}
if(digitalRead(10)==LOW && a==true){
a = false;
if(x==1){
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
}
if(x==2){
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
}
if(x==3){
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
}
if(x==4){
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
}
if(x==5){
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
}
if(x==6){
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
}
if(x==7){
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
}
}
else if(digitalRead(10)==HIGH && a==false){
a= true;}
}