lcd problem

Hi
I am using a DFROBOT button Lcd shield and using the sketch I am playing with the numbers up to 100 have a 0 after them so 12 turns out as 120 could you please put me right.

#include <LiquidCrystal.h> // Use the standard library

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
lcd.begin(16, 2); // set up the LCD’s number of columns and rows
lcd.print(" A02 Value"); // Print hello world to the first line
pinMode(10, OUTPUT); // Set up pin 10 for the backlight control
pinMode(0, INPUT); // Set up pin 0 to read the keypad
}

void loop()
{
analogWrite(10,255 ); // Set the backlight to full brightness
int log2=analogRead(2); // Read the value from keypad
lcd.setCursor(6, 1); // Set the cursor to column 0, line 1
lcd.print(log2/4); // Print the key pad value to the second line
}

sorry but I am new to this.
Regards
Bill.

Bill,

Either do the lazy way of:

if (number<100) lcd.print(" "); // Add one leading space for 11-99
if (number<10) lcd.print(" "); // Add another leading space for 0-9
lcd.print(number); // Actually prints the number

or learn how to properly format a number for output with sprintf so you have total control of how your number looks (leading empty space or leading zero or no leading anything etc.):

Thankyou liudr It is working great now. I will read and learn this is my first play at altering a sketch. Thanks again Bill

billyboy1959: Thankyou liudr It is working great now. I will read and learn this is my first play at altering a sketch. Thanks again Bill

I thought that was why I provided a lazy man's solution for your instant gratification and then some for later on. Have fun exploring Arduino and coding :)