Help Needed

void loop() {
//Reading values for buttons lcd keypad shield
{ int x;
x = analogRead (0);
lcd.setCursor(a,1);

//up button
if (x < 200)
{ ans= constrain(ans+1,0,40);
lcd.print(ans);
lcd.print(" ");
}

//down button
else if (x < 400)
{ ans= constrain(ans-1,0,40);
lcd.print(ans);
lcd.print(" ");
}

//Select Button to take input
else if (x < 800)
{ value1=ans;
value2 = value1*20;

//Displaying User Selected Value
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Selected Qty : ");
lcd.setCursor(13,0);
lcd.print(value1);
delay(3000);

lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Now Add weight to Beam");

}

delay(200);

}

//reading the value of weight added by user

float w = abs(scale.get_units()*10);
scale.set_scale(calibration_factor); //Adjust to this calibration factor

if ( w >= value2)
{
digitalWrite(buzPin,HIGH);
lcd.clear();
lcd.setCursor(3,0);
lcd.print(“STOP ADDING”);
}
else
{
lcd.clear();
digitalWrite(buzPin,LOW);
lcd.setCursor(4,0);
lcd.print(“ADD MORE”);
}

}

This is the code when i m executing, system doesnot allows me make use of up, down or select buttons, to select a value but rather pushes me out and LCD starts displaying "STOP ADDING.

M using LCD Keypad Shield and using only up , down , select and reset buttons , connected to HX711 to load cell .

You would need to add code to use the buttons, you don’t have any. Look at the button example sketches that ship with the IDE.

Whenever you post code, post the entire sketch, not just half of it. I can see that it’s not all there. Also, the forum posting guideline is to use code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don’t do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The “Code: [Select]” feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing or review.

If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower right corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

(deleted)

ohk.. thanks.. next time will take care..i just solved my issue.

yuug_s:
ohk.. thanks.. next time will take care..i just solved my issue.

How did you solve it? It would be nice of you to share the solution, for people who have similar problems, and read this thread later.

smarts-jb:
OP says they have an lcd keypad shield, and although the make and model is not specified, this line:

x = analogRead (0);

Using a name for the switches other than 'x' would have given the reader a clue...

(deleted)