Hello, I would like to know how to insert black box character in LCD. I know that it's lcd.print(char(255)); but I need to know hoe to insert it for several positions below set.Cursor(8,0); int that particular case there would be 8 black boxes. Experience is: I am taking mesurement with potentiometer and instead of reading value of potentiometer, I read black boxes from (0 to 16)
If you mean a bar graph, look here: Arduino Playground - LcdBarGraph Library
Or just google "arduino lcd bar graph" or "arduino lcd custom characters"
Thank's!
My code is not working properly if I want to use first line of LCD. It shows bars graph on the first and second lines of LCD. I have to comment this part to display the graph on the second line:
// drawing black rectangles on LCD
//if(b>=1) {
// for(int i=1;1<b;i++){
// lcd.print(char(255));
// c=i;
// }
// b=b-c;
//}
My code:
#include <LiquidCrystal.h>
#define longueur1 16.0
#define longueur2 16.1
float percent1;
float percent2;
unsigned char c;
unsigned char d;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
delay(100);
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(0, 0);
//ADC conversion
unsigned int Potant1 = analogRead(A12);
unsigned int Potant2 = analogRead(A15);
percent1 = Potant1/1024.0*100.0;
lcd.setCursor(0,0);
float b=longueur1/100*percent1;
// drawing black rectangles on LCD
//if(b>=1) {
// for(int i=1;1<b;i++){
// lcd.print(char(255));
// c=i;
// }
// b=b-c;
//}
percent2 = Potant2/1024.0*100.0;
lcd.setCursor(0,1);
float a=longueur2/100*percent2;
// drawing black rectangles on LCD
if (a>=1) {
for (int i=1;i<a;i++){
lcd.print(char(255));
d=i;
}
a=a-d;
}
//efface la ligne
for (int i =0;i<(longueur1-d);i++) {
lcd.print(" ");
}
for (int i =0;i<(longueur2-c);i++) {
lcd.print(" ");
}
delay(500);
}
Typo which will fill entire lcd memory with black boxes and wrap to second line.
for(int i=1;1<b;i++)
should be
for(int i=1;i<b;i++)