int buttonState1 = 0;
int buttonState2 = 0;
int buttonPin1 = 4;
int buttonPin2 = 6;
int power = 0;
int menuState = 0; //Channel Surf = 1, Channel input = 2, Volume = 3, Power = 4;
int displayState = 0; //Channel Surf = 1, Channel input = 2, Volume = 3, Power = 4;
int CS = 0; //Channel up = 1, Channel down = 2, Exit = 3
int CI = 0; //hundreds = 1, tens = 2, single = 3, Exit = 4
int vol = 0; //Volume up = 1, Volume down = 2, Exit = 3
void setup(){
Serial.begin(9600);
}
void loop(){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if(power == 0){
if(buttonState1 == 1){
power = 1;
}
else if(buttonState2 == 1){
power = 1;
}
if(power == 1){
//transmit code to turn power on
displayState = 1;
}
buttonState1 = 0;
buttonState2 = 0;
}
if (power == 1){
//switch through main menu
if(menuState == 0){
if(displayState == 1){
//LCD Displays Channel Surf Menu
}
if(displayState == 2){
//LCD Displays Channel Input menu
}
if(displayState == 3){
//LCD Displays Volume Menu
}
if(displayState == 4){
//LCD Displays Power Menu
}
if(buttonState2 == 1){
displayState = displayState + 1;
if(displayState == 5){
displayState = 1;
}
}
}
//go into the menu (not just display)
if(buttonState1 = 1){
menuState = displayState;
}
//Channel Surf Menu
if (menuState == 1){
CS = 1;
if(buttonState2 == 1){
CS = CS+1;
if(CS == 4){
CS = 1;
}
}
if(buttonState1 == 1){
if(CS == 1){
//transmit code to switch channel up
}
if(CS == 2){
//transmit code to switch channel down
}
if(CS == 3){
menuState = 0;
}
}
}
//Channel Input Menu
if (menuState == 2){
int hundreds = 0;
int tens = 0;
int ones = 0;
CI = 1;
if(buttonState2 == 1){
CI = CI + 1;
if (CI = 5){
CI = 1;
}
}
if(buttonState1 == 1){
if(CI == 1){
hundreds = hundreds + 1;
if(hundreds == 10){
hundreds = 0;
}
}
if(CI == 2){
tens = tens + 1;
if (tens == 10){
tens = 0;
}
}
if(CI == 3){
ones = ones + 1;
if (ones == 10){
ones = 0;
}
}
if(CI == 4){
menuState = 0;
}
}
}
if (menuState == 3){
Vol = 1;
if(buttonState2 == 1){
Vol = Vol+1;
if(Vol == 4){
Vol = 1;
}
}
if(buttonState1 == 1){
if(Vol == 1){
//transmit code to switch volume up
}
if(Vol == 2){
//transmit code to switch volume down
}
if(Vol == 3){
menuState = 0;
}
}
}
if (menuState == 4){
if (buttonState1 == 1){
//transmit code o switc TV off
power = 0;
}
if (buttonState2 == 1){
menuState = 0;
}
}
}
}
int buttonState2 = 0;
int buttonPin1 = 4;
int buttonPin2 = 6;
int power = 0;
int menuState = 0; //Channel Surf = 1, Channel input = 2, Volume = 3, Power = 4;
int displayState = 0; //Channel Surf = 1, Channel input = 2, Volume = 3, Power = 4;
int CS = 0; //Channel up = 1, Channel down = 2, Exit = 3
int CI = 0; //hundreds = 1, tens = 2, single = 3, Exit = 4
int vol = 0; //Volume up = 1, Volume down = 2, Exit = 3
void setup(){
Serial.begin(9600);
}
void loop(){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if(power == 0){
if(buttonState1 == 1){
power = 1;
}
else if(buttonState2 == 1){
power = 1;
}
if(power == 1){
//transmit code to turn power on
displayState = 1;
}
buttonState1 = 0;
buttonState2 = 0;
}
if (power == 1){
//switch through main menu
if(menuState == 0){
if(displayState == 1){
//LCD Displays Channel Surf Menu
}
if(displayState == 2){
//LCD Displays Channel Input menu
}
if(displayState == 3){
//LCD Displays Volume Menu
}
if(displayState == 4){
//LCD Displays Power Menu
}
if(buttonState2 == 1){
displayState = displayState + 1;
if(displayState == 5){
displayState = 1;
}
}
}
//go into the menu (not just display)
if(buttonState1 = 1){
menuState = displayState;
}
//Channel Surf Menu
if (menuState == 1){
CS = 1;
if(buttonState2 == 1){
CS = CS+1;
if(CS == 4){
CS = 1;
}
}
if(buttonState1 == 1){
if(CS == 1){
//transmit code to switch channel up
}
if(CS == 2){
//transmit code to switch channel down
}
if(CS == 3){
menuState = 0;
}
}
}
//Channel Input Menu
if (menuState == 2){
int hundreds = 0;
int tens = 0;
int ones = 0;
CI = 1;
if(buttonState2 == 1){
CI = CI + 1;
if (CI = 5){
CI = 1;
}
}
if(buttonState1 == 1){
if(CI == 1){
hundreds = hundreds + 1;
if(hundreds == 10){
hundreds = 0;
}
}
if(CI == 2){
tens = tens + 1;
if (tens == 10){
tens = 0;
}
}
if(CI == 3){
ones = ones + 1;
if (ones == 10){
ones = 0;
}
}
if(CI == 4){
menuState = 0;
}
}
}
if (menuState == 3){
Vol = 1;
if(buttonState2 == 1){
Vol = Vol+1;
if(Vol == 4){
Vol = 1;
}
}
if(buttonState1 == 1){
if(Vol == 1){
//transmit code to switch volume up
}
if(Vol == 2){
//transmit code to switch volume down
}
if(Vol == 3){
menuState = 0;
}
}
}
if (menuState == 4){
if (buttonState1 == 1){
//transmit code o switc TV off
power = 0;
}
if (buttonState2 == 1){
menuState = 0;
}
}
}
}