Thank You Mr. Datman
#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 VoltageOut = 0.0;
float VoltageIn = 0.0;
int refresh = 50; //refresh rate
int i = 0; //variable used for clearing our byte 'graph'
int value = 0; //variable to store value
byte graph[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
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
//VoltageOut = (value * 5.0) / 1024.0;
VoltageIn = (value * 5.0) / 1024.0;
//VoltageOut / (R2/(R1+R2));
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()
{
if (VoltageIn >= 0.3125) //setting up the bar graph
{
lcd.setCursor(0,2);
lcd.print('█'); }
else
{
lcd.print(' ');
}
if (VoltageIn >= 0.625)
{
lcd.setCursor(1, 2);
lcd.print('█'); }
else
{
lcd.print(' ');
}
if (VoltageIn >= .9375)
{
lcd.setCursor(2, 2);
lcd.print('█');}
else
{lcd.print(' ');
}
if (VoltageIn >= 1.25){
lcd.setCursor(3, 2);
lcd.print('█');}
else
{lcd.print(' ');
}
if (VoltageIn >= 1.5625)
{
lcd.setCursor(4, 2);
lcd.print('█');}
else
{
lcd.print(' ');
}
if (VoltageIn >= 1.875)
{
lcd.setCursor(5, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 2.1875)
{
lcd.setCursor(6, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 2.5)
{
lcd.setCursor(7, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 2.8125)
{
lcd.setCursor(8, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 3.125)
{
lcd.setCursor(9, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 3.4375)
{
lcd.setCursor(10, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 3.75)
{
lcd.setCursor(11, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 4.0625)
{
lcd.setCursor(12, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 4.375)
{
lcd.setCursor(13, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 4.6875)
{
lcd.setCursor(14, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
if (VoltageIn >= 4.99)
{
lcd.setCursor(15, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
}
}
Not working right for me. I dont know how somewhere is unknown text 27000 on the lcd, like[ -----------27000]. Incomprehensible. My problem is :
I like to see ONLY ONE sign in the right place on the lcd like indicator pointer multimeter [ - ]
if (VoltageIn >= 2.5)
{
lcd.setCursor(7, 2);
lcd.print('█');
}
else
{
lcd.print(' ');
Cannot delete unwanted left-hand boxes [-------- ]
Need make on the LCD display bargraph like this : post 11
Multidisplay, a Open Source inCar Display, Logger - Exhibition - Arduino Forum
Lambda display view.
Original code in C++ is GitHub - designer2k2/multidisplay: The MultiDisplay Project, An opensource datalogger, boost controller and display for cars GitHub - designer2k2/multidisplay: The MultiDisplay Project, An opensource datalogger, boost controller and display for cars
As i am not programmer, i cannot make C++ working in the Arduino . Problem is in deleting redundant boxes before necessary black box.