A project that I am starting will have a Parallax 4 x 20 serial LCD. What I am wanting to do is program a a kindof scrolling menu with 3 buttons. One to scroll up, another to scroll down, and the last to select the option that is printed on the LCD. I don't really know where to start on how to program this, but if anyone give some advice or insight it will be greatly appreciated. Thanks.
Thanks for the links, I changed up my design some just to play around with. Right now instead of using 2 buttons to scroll I have a 0-9 dual pushwheel switch to dial through. I still want to put in a button to select the showing option but I'm still working on it. I also have it all hooked up to the LCD. Here is a copy of the code I have now, its a lot and a little messy but I'm learning. If I decide to not include the 3rd button I might just put a delay on what I want to happen.
const int led1 = 4;
const int led2 = 5;
const int led3 = 6;
const int led4 = 7;
const int sw1 = 13;
const int sw2 = 12;
const int sw3 = 11;
const int sw4 = 10;
const int lcd = 1;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
void setup(){
Serial.begin(9600);
pinMode(lcd,OUTPUT);Serial.write(12);Serial.write(131);Serial.write("The Bartender");
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(sw1,INPUT);
pinMode(sw2,INPUT);
pinMode(sw3,INPUT);
pinMode(sw4,INPUT);
}
void loop(){
val1 = digitalRead(sw1);
val2 = digitalRead(sw2);
val3 = digitalRead(sw3);
val4 = digitalRead(sw4);
if(val1 == HIGH){digitalWrite(led1,HIGH);Serial.write(168);Serial.write("Opt 1");} // led 1 on, print opt 1 on screen
if(val2 == HIGH){digitalWrite(led2,HIGH);Serial.write(173);Serial.write("Opt 2");} // led 2 on, print opt 2 on screen
if(val3 == HIGH){digitalWrite(led3,HIGH);Serial.write(178);Serial.write("Opt 3");} // led 3 on, print opt 3 on screen
if(val4 == HIGH){digitalWrite(led4,HIGH);Serial.write(183);Serial.write("Opt 4");} // led 4 on, print opt 4 on screen
if(val1 == LOW){digitalWrite(led1,LOW);Serial.write(168);Serial.write(" ");} // led 1 off, print *blank* on screen
if(val2 == LOW){digitalWrite(led2,LOW);Serial.write(173);Serial.write(" ");} // led 2 off, print *blank* on screen
if(val3 == LOW){digitalWrite(led3,LOW);Serial.write(178);Serial.write(" ");} // led 2 off, print *blank* on screen
if(val4 == LOW){digitalWrite(led4,LOW);Serial.write(183);Serial.write(" ");} // led 2 off, print *blank* on screen
}
I am trying to do understand what u r trying here,
Here your judging on status pin. when you checking status High or loW.
Assume you said
- problem statement from your code
if(pin==HIGH)
{
do this...................
}else // means your selected pin is low , so dont use multiple if statement so it take long time to check condition
{
Which ur writing end of code
}
- problem statement.
you should know what is condition of other pin when particular pin set high or Low.