LCD Horizontal bargraph like one black rectangle

Hi Tilt

My bad it should have been 16 spaces to clear the whole line not 15.

Ian

Tiit:
Thank You Datman and IanCrowe!
I like for my ad8307 voltmeter project IanCrowe code:

/*

Code from IanCrowe  LCD Horizontal bargraph like one black rectangle - Programming Questions - Arduino Forum
post 11 with one little supplement clearing last box too.
Thank You Iancrowe!
*/
#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //initialize the library, numbers of the interface pins

int analogInput = 1;    //analog pin A1
  float VoltageIn = 0.0;  // Used to calculate and display voltage
  int refresh = 500;      //refresh the display every half second
  int i = 0;                  //variable used for clearing our byte 'graph'
  int value = 0;            //variable to store value from analogRead

void setup()
{
  pinMode(analogInput, INPUT);  //setting analog pin mode to input

lcd.begin(16, 2);            //setting up the LCD screens rows and colums
  lcd.print("Voltage=");     
}

void loop(){
  value = analogRead(analogInput);  //reading the value on A1

VoltageIn = (value * 5.0) / 1024.0;

lcd.setCursor(8, 0);              //printing the result to the LCD display
  lcd.print(VoltageIn);
  lcd.print(" V");
  delay(refresh);                    //refreshing the screen

voltmetergraph();                  //calling my function voltmetergraph
}

void voltmetergraph()
  {
      int position = map(value, 0, 1023, 0, 15);
      lcd.setCursor(0,1);        // move the cursor to the start of the second line
      lcd.print("                ");  // clear the second line by writing 15 spaces(
                                      //For clearing last box-5v too, needed 16 spaces if first is 1.
      lcd.setCursor(position, 1);  // Move to the correct position on the line
      lcd.write(255);                // print a block
  }




Much thanks!
73!

Tiit