But when I run the example CustomCharacter sketch which is distributed with the LiquidCrystal library examples, it does not compile as given.
Here are the errors:
CustomCharacter.ino: In function ‘void setup()’:
CustomCharacter.ino:115:14: error: call of overloaded ‘write(int)’ is ambiguous
CustomCharacter.ino:115:14: note: candidates are:
In file included from CustomCharacter.ino:39:0:
/usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h:82:18: note: virtual size_t LiquidCrystal::write(uint8_t)
virtual size_t write(uint8_t);
^
In file included from /usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h:5:0,
from CustomCharacter.ino:39:
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h:49:12: note: size_t Print::write(const char*)
size_t write(const char *str) {
^
Changing the declarations from type "byte" to "uint8_t" did not fix the problem. But after I changed the write statements from, for example:
lcd.write(3);
to:
lcd.write(byte(3));
the sketch works as intended.
I know there are lots of ways of doing things, so I might be wrong, but I think it is important that examples which are distributed with the libraries run with no errors.
If I'm correct, I don't know which forum to use to report it.
keithostertag:
Total newbie here, so I may be wrong...
lcd.write(3);
to:
lcd.write(byte(3));
the sketch works as intended.
I know there are lots of ways of doing things, so I might be wrong, but I think it is important that examples which are distributed with the libraries run with no errors.
If I'm correct, I don't know which forum to use to report it.
Hope this helps.
Thanks,
Keith Ostertag
The LCD library hooks into the Print.cpp and Print.h code which is common to a lot of drivers that send text data to devices. It's not an LCD problem.
When you said "lcd.write (3)" you told the code "write a 16 bit integer with the value of 3" which the base write code cannot do. Sure the value "3" is well within an 8 bit byte, but how is the compiler supposed to know to use the lower part of an int and throw away the upper half?
Now, when you said "lcd.write ((byte) 3)" you explicitly said that "3" was an 8 bit value and there was no problem sending it to the LCD.
You could also have done these things:
byte num = 3;
// or
char num = 3;
lcd.write (num);
... or you could have done this....
lcd.write ("\x03");
BTW, you should use PRINT, not WRITE. For example, if you try to do this:
lcd.write ("Hello"), it will fail since WRITE can only handle one byte. You would want lcd.print ("Hello"); (or lcd.print (anything-else)).