Character animation

Hi!

I having some trouble getting this code working. I cant see why!
It is suppose to work like this:

  1. The cup has to stay on all the time
  2. The stream have to switch between the to str animations

Here is my code

// include the library code:
#include  <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins:
LiquidCrystal lcd(11, 10, 5, 4, 3, 2);

// setting animation speed (delay between frames)
int x = 500;

void setup() {
	// set up the LCD's number of columns and rows:
	lcd.begin(20,4);
	// clear the LCD screen:
	lcd.clear();
}

void loop() {
  
        cup();
        strA();
        delay(x);
        strB();
        delay(x);
}

void cup() {
  byte cup1[8] = {B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};
  byte cup2[8] = {B11111,B11111,B11111,B11111,B01111,B00111,B00001,B00000};
  byte cup3[8] = {B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};
  byte cup4[8] = {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B00000};
  byte cup5[8] = {B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};
  byte cup6[8] = {B11111,B11111,B11111,B11111,B11110,B11100,B10000,B00000};
  byte cup7[8] = {B00000,B00000,B00000,B00000,B00000,B00000,B11100,B00110};
  byte cup8[8] = {B00110,B11100,B00000,B00000,B00000,B00000,B00000,B00000};
  lcd.createChar(0, cup1);
  lcd.createChar(1, cup2);
  lcd.createChar(2, cup3);
  lcd.createChar(3, cup4);
  lcd.createChar(4, cup5);
  lcd.createChar(5, cup6);
  lcd.createChar(6, cup7);
  lcd.createChar(7, cup8);
  lcd.setCursor(8,2);
  lcd.write(0);
  lcd.setCursor(8,3);
  lcd.write(1);
  lcd.setCursor(9,2);
  lcd.write(2);
  lcd.setCursor(9,3);
  lcd.write(3);
  lcd.setCursor(10,2);
  lcd.write(4);
  lcd.setCursor(10,3);
  lcd.write(5);
  lcd.setCursor(11,2);
  lcd.write(6);
  lcd.setCursor(11,3);
  lcd.write(7);
}

void strA() {
  byte str1[8] = {B01110,B01110,B01110,B00000,B00000,B00000,B00000,B00000};
  byte str2[8] = {B01110,B01110,B01110,B00000,B00000,B00000,B00000,B00000};
  lcd.createChar(0, str1);
  lcd.createChar(1, str2);
  lcd.setCursor(9,0);
  lcd.write(0);
  lcd.setCursor(9,1);
  lcd.write(1);
}

void strB() {
  byte str1[8] = {B00000,B00000,B00000,B00000,B01110,B01110,B01110,B01110};
  byte str2[8] = {B00000,B00000,B00000,B00000,B01110,B01110,B01110,B01110};
  lcd.createChar(0, str1);
  lcd.createChar(1, str2);
  lcd.setCursor(9,0);
  lcd.write(0);
  lcd.setCursor(9,1);
  lcd.write(1);


}

And here is how it works...

Any ideas?!

If your code works, what does it do? What kind of cup doing what animation? Can you sketch a picture on a piece of paper to demonstrate?

If your code works, what does it do?

Have a look at the youtube link

Can you sketch a picture on a piece of paper to demonstrate?

Here is a little sketch.

The "x" (cup) has to stay on all the time (not the x's at the side and bottom)
The "s" (strA) and "r" (strB) has to switch between each other, so it looks like there is dripping something into the cup

But the problem is, as shown in the video, something is messing it up.

Could it be because createChar only allows 0-7 custom characters shown simultaneously on the LCD? :roll_eyes:

Could it be because createChar only allows 0-7 custom characters shown simultaneously on the LCD?

Yes, but it is a limitation of the LCD controller not creatChar().

Don

Now that you have drawn a picture of what was supposed to happen the video makes more sense.

It looks like three of your eight memory locations contain the same information.

Also, if necessary, you can probably rework things so that only one of the eight memory slots is used for both of the strings used for the 'drips'. You would have to reload that location between drips.

Don

Ahh okay.. Thanks a lot!

I have been trying to replace some of the custom characters with the extended ASCII codes from http://www.asciitable.com/

More precise extended characters 219 - 223 (filled boxes) I have tried different codes from this thread:

http://arduino.cc/forum/index.php/topic,78119.0.html

Dont all LCD drivers support extended characters?

My LCD:

http://www.seeedstudio.com/depot/images/product/LMB204BFC-Manual-Rev0.1.pdf

Are there any ASCII tables where characters 1-31 are shown i pictures?

If you can afford this alternative, see attachment, then you will only need to define 3 custom characters for the cup. The center is the character 255 so it comes free. The cup handle is one character instead of 2 so saving you one additional character. Plus the cup is just one row shorter so there is no need for the 4*5 blocks you are using.

As a matter of fact, HD44780 display only has roughly 32-125 compatible with ASCII (note, American AKA USA standard, and HD is probably Hitachi display, ie. Japan). Typical HD44780 displays have code page A00, with the 128-255 filled with Japanese and some Greek and some symbols, not your expected extended ASCII with some blocks and twigs for drawing tables. Code page A02 (I guess some displays are outfitted with this) is crazier but still no blocks.

cup.gif

Your questions indicate that you are not really familiar with what the ASCII codes really are - and you are not alone. Wikipedia has a good explanation (ASCII - Wikipedia) and you can find a good chart and an explanation if you follow either of the ASCII links at http://web.alfredstate.edu/weimandn.

Here are some salient points:

ASCII is a seven bit coding system so there can only be 128 characters, numbered 00 - 7F in hex or 0 - 127 if you insist on using decimal.

There is no discernable pattern to the codes if you use decimal and the patterns are hard but not impossible to discern if you use hex. Binary is best.

The 'A' in ASCII stands for American, so don't be surprised when you don't find any 'foreign' characters in those 128 characters.

The first 32 codes (00 - 1F) are non printable control codes leaving 96 displayable characters, one of which (20) is a blank an another of which (7F) was used to blot out incorrect characters.

Since ASCII is a 7-bit code and most microprocessor systems use 8-bit bytes the extra (high) bit is used to define the 'extended ASCII' codes.

Most LCD controller manufacturers use a 256 byte block of memory for their displayable codes but only the codes corresponding to the displayable ASCII codes (20 - 7E) are anywhere near standard. The characters for all of the other codes vary from manufacturer to manufacturer and from one ROM to another even from the same manufacturer.

The first 16 codes are reserved for the special characters that you can create with lcd.createChar() but due what is called foldback memory addressing you can only use eight of them (00 - 07). The other eight memory addresses (08 - 1F) are just 'back doors' to the first eight locations.

Now to answer your questions:

I have been trying to replace some of the custom characters with the extended ASCII codes from http://www.asciitable.com/

Those extended codes look like the ones used by IBM when they designed the original PC. They will probably work as advertised on your computer. Hold down the [ALT] key and type in one of the three digit decimal (ugh) numbers on your keypad (not the row of numbers above the letters) and see what you get.

http://arduino.cc/forum/index.php/topic,78119.0.html

Dont all LCD drivers support extended characters?

Yes, but they are not all the same as each other, and none matches those used on a computer.

http://www.seeedstudio.com/depot/images/product/LMB204BFC-Manual-Rev0.1.pdf

Are there any ASCII tables where characters 1-31 are shown i pictures?

That's not a complete data sheet. On page 3 it claims to use an ST7066U controller and the data sheet for that controller shows that there are two possible ROMs with different characters in each.

Don

The center is the character 255 so it comes free.

Maybe, that depends on your ROM. It's OK on Hitachi controllers with ROM Code A00 but not A02. It's OK on Sitronix controllers with ROM Code 0A but not 0B.

Don