Go Down

Topic: Loading Bar on an 16x2 parallel LCD? Help! (Read 1 time) previous topic - next topic

TheMakersWorkbench

I am trying to create a faux loading bar on my LCD. I want to completely fill each column in the second row one at at time at .5 sec intervals until all 16 columns are filled.

The fill I am talking about is the second character on the second row in this pic.


I was thinking I could use the autoScroll function for this but am having trouble figuring out what the DEC code is for that character and how to put it all together. In the extended ASCII table that character shows up as 219 but on my LCD 219 shows up as a hollow box.

TheMakersWorkbench

Ok I created a custom character that fills the a whole column and got it to print a new one every .5 seconds for 8 seconds but it now stops my message on line 1 from scrolling. Can anyone tell me what I am doing wrong here?

Code: [Select]
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

byte block[8] =
{
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111
};

void setup() {
 // set up the LCD's number of rows and columns:
 lcd.begin(16, 2);
 //lcd.setCursor(0,7);
 // Print a message to the LCD.
 lcd.print("Satcomm Information Initializaion");
 delay(10);
 lcd.createChar(7,block);
 }

void loop() {
 // scroll 13 positions (string length) to the left
 // to move it offscreen left:
 {
 for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
   // scroll one position left:
   lcd.scrollDisplayLeft();
   // wait a bit:
    delay(50);  
   lcd.setCursor(0,1);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
     }

 
 }}

Casey Gross

Try this, tell me what happens.

Code: [Select]
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

byte block[8] =
{
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111
};

void setup() {
 // set up the LCD's number of rows and columns:
 lcd.begin(16, 2);
 //lcd.setCursor(0,7);
 // Print a message to the LCD.
 lcd.print("Satcomm Information Initializaion");
 delay(10);
 lcd.createChar(7,block);
 }

void loop() {
 // scroll 13 positions (string length) to the left
 // to move it offscreen left:
 
 for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
   // scroll one position left:
   lcd.scrollDisplayLeft();
   // wait a bit:
    delay(50);
 }
   lcd.setCursor(0,1);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
   delay(500);
   lcd.write(7);
 }

mrmeval

#3
Jun 12, 2010, 09:09 pm Last Edit: Jun 12, 2010, 09:20 pm by mrmeval Reason: 1
The scroll function moves the entire screen left or right. I broke the two things you're wanting to do in half. I modified the custom font only because my display has a gap between all the other lines and the bottom line, it looks icky, you can change it back to your original if you have a better display.

Now the text scrolls then the bar advances. This is set to repeat. I had to clear the screen, scroll the displayed text, go back to home then go to the second line and generate the bar.

I got rid of the evil lcd.write list. ;)

Now if you Just Must Have The Top Scroll while the bar is working you will have to figure out how to put the characters and the bar on the screen and advance them without the bottom line shifting. Good luck. :-P

Your picture shows an 8x2 display. If that is going to be used you'll need to make some code and format changes.


Code: [Select]
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

byte block[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B00000
};

void setup() {
// set up the LCD's number of rows and columns:
lcd.createChar(7,block);
lcd.begin(16, 2);
//lcd.setCursor(0,7);
   delay(10);

}

void loop() {
// scroll 24 positions (string length) to the left
// to move it offscreen left:
lcd.clear();
lcd.print("Satcomm Information Initialization");
for (int positionCounter = 0; positionCounter < 24; positionCounter++) {
  // scroll one position left:
  lcd.scrollDisplayLeft();
  delay(300);
  }
  lcd.home();
  lcd.setCursor(0,1);
  for (int x=0; x < 16 ; x++){
    delay(200);
  lcd.write(7);}
 
}
If it was designed by man it can be repaired by man.

mrmeval

#4
Jun 12, 2010, 09:37 pm Last Edit: Jun 12, 2010, 09:37 pm by mrmeval Reason: 1
To print the character built into the display use

lcd.write(255);

It auto advances to the next position.  There is a lookup table here
http://home.iae.nl/users/pouweha/lcd/lcd0.shtml#charset

The code is binary.


If it was designed by man it can be repaired by man.

floresta

Quote
To print the character built into the display use
lcd.write(255);
This may or may not work depending on the particular CGROM in the LCD controller.  Only the printable ASCII codes (32 - 127) are likely to be the same for all devices.

Quote
There is a lookup table here http://home.iae.nl/users/pouweha/lcd/lcd0.shtml#charset
This is basically a rewrite of the Hitachi datasheet and shows the character set for one of the Hitachi CGROM variations.

Quote
The code is binary.
Huh?

Don

Go Up