I'm making a roulette on my lcd and I can't seem to lock certain functions. here is my code. I want to make it so that when I press select, I can no longer use the left right up down buttons.
long randNumber;
int x;
int y;
int z;
int a;
int b;
int c;
int chips;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
lcd.begin(16, 2);
y = 100;
b = 1;
a = 1;
c = 1;
x = 1;
}
void loop() {
if (c=1){
int z = analogRead (0);
if (z < 60 ){ //right
lcd.setCursor (0, 1);
lcd.print("black");
delay (200);
}
else if (z < 200) {
}
else if (z < 400 )
{
x = x + 1; //up
delay (200);
}
else if (z < 600 ) {
x = x - 1; //down
delay (200);
}
else if (z < 800 ) {
c= 2;
lcd.setCursor (0, 1);
lcd.print ("red "); //Left
delay (200);
}
else { // select
chips = 2;
}}
if (x < 1) {
x = y;
}
else if (x > y) {
x = 1;
}
else if (x < 10) {
lcd.setCursor(1, 0);
lcd.print(" ");
}
else if (x < 100) {
lcd.setCursor(2, 0);
lcd.print(" ");
}
else if (x < 1000) {
lcd.setCursor(3, 0);
lcd.print(" ");
}
lcd.setCursor(12, 0);
lcd.print (y);
lcd.setCursor (0, 0);
lcd.print (x);
delay (0);
}
It would be helpful if you formatted the code so that it was properly indented. I also found that the spurious blank lines made it a little harder to follow.
Before I could follow your code I copied it into the IDE then did select all and tools -> auto format. Then I removed the spurious blank lines.
By the time I spotted the two things: = used in if statement, and delay(0), which I was going to comment on, the above post had already been made.
If I were you I would start by fixing the =/== problem then give the variables meaningful names. As it is I have no idea what you mean by select, up, down, left or right
It looks like you are using an LCD shield with 5 built in buttons on a Uno board but that is a guess
Your variables have no meaningful names.
This makes it very hard for other users what variable does what.
You should unload the work of this time-consuming work from the shoulders of your potential helpers. And last but not least giving each and every name in your code a meaningful name will make it easier for yourself to maintain your code