Caracteres Speacial

I compile example of librarie for use new own caracthers and dont compile because there are one error. Why?
THis is code is one example of library

Error is
Call of overloaded "write(int)" is ambiguous

WHY?
can you help me?

/*
LiquidCrystal Library - Custom Characters

Demonstrates how to add custom characters on an LCD display.
The LiquidCrystal library works with all LCD displays that are
compatible with the Hitachi HD44780 driver. There are many of
them out there, and you can usually tell them by the 16-pin interface.

This sketch prints "I Arduino!" and a little dancing man
to the LCD.

The circuit:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • 10K potentiometer:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)
  • 10K poterntiometer on pin A0

created21 Mar 2011
by Tom Igoe
Based on Adafruit's example at

This example code is in the public domain.

Also useful:
http://icontexto.com/charactercreator/

*/

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

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

// make some custom characters:
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};

byte smiley[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b10001,
0b01110,
0b00000
};

byte frownie[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b00000,
0b01110,
0b10001
};

byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};

byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
void setup() {
// create a new character
lcd.createChar(0, heart);
// create a new character
lcd.createChar(1, smiley);
// create a new character
lcd.createChar(2, frownie);
// create a new character
lcd.createChar(3, armsDown);
// create a new character
lcd.createChar(4, armsUp);

// set up the lcd's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the lcd.
lcd.print("I ");
lcd.write(0);
lcd.print(" Arduino! ");
lcd.write(1);

}

void loop() {
// read the potentiometer on A0:
int sensorReading = analogRead(A0);
// map the result to 200 - 1000:
int delayTime = map(sensorReading, 0, 1023, 200, 1000);
// set the cursor to the bottom row, 5th position:
lcd.setCursor(4, 1);
// draw the little man, arms down:
lcd.write(3);
delay(delayTime);
lcd.setCursor(4, 1);
// draw him arms up:
lcd.write(4);
delay(delayTime);
}

I believe that your problem is here: lcd.write(0);

Try using this: lcd.write(8);

Don

Yes this make code compile good. But I have some questions.

1º.- Why 8 and no 0, I thinked if I make 8 carachters new named 0 to 8
when I call for write in LCD I make lcd.write(4); for example.
Why can I do lcd.write(8); and cant do lcd.write(0);
How can I print in my lcd each new special caracteres.

2º.-This example was copy and paste directly of LiquidCrystal Library - Custom Characters from Arduino complirer
Is this arduino example bad?

I only need print in my LCD two caracthers new, one "up arrow" and one "down arrow"

How do I must do this?
I made this in setup

byte up_arrow[8] = {
B00100,
B01110,
B10101,
B00100,
B10100,
B00100,
B00100,
};

byte down_arrow[8] = {
B00100,
B00100,
B00100,
B00100,
B10101,
B01110,
B00100,
};

lcd.createChar(0,up_arrow);
lcd.createChar(1,down_arrow);

and in my loop I thinked I must print on lcd display with

lcd.write(0);
lcd.write(1);

what is my error?

Thank you again and excuse my bad english

Why 8 and no 0...

The fact that '0' does not compile has to do with the way the 'C' interpreter works. I don't know all the details but when bill (bperrybap) sees this he can explain it to you.

The reason that '8' works is due to what is called 'foldback memory addressing'. The eight custom characters have redundant addresses due to that characteristic of the LCD controller. Addresses 0x00 <--> 0x07 (0 <--> 7) are the primary addresses and addresses 0x08 <--> 0x1F (8 <--> 15) are the foldback (redundant) addresses for the same eight characters.

Don

Thank you again.......I tryed with 1 and 8 and work perfect.
NIce.....
Thanl you again

zero as a naked constant is kind of a special value in C because it can be interpreted as different things.
It could be pointer or a numeric value.
It has been the cause of many colorful discussions through several decades.

In this case the way the Arduino Print class is defined in Print.h there are three versions of write()

- write(uint8_t); // takes a numeric byte value
- write(const uint8_t *buffer, size_t size); // takes a pointer to a buffer and its length
- write(const char *str); // takes a pointer to a C string

So the problem is that since zero is special and can be either a number or a pointer, the
compiler has no way of knowing which version of the write() function you wanted to call.
It could be the write() that takes a byte value or it could be the write() that takes a pointer.

Just my opinion but I think the 3rd definition should not exist. It isn't necessary since
there is a print() function to handle C strings.
Eliminating this extra write function would clear up the issue.

Anyway, to work within the current environment,
the easiest thing to do is to always cast the value into your intended type so that that the compiler will
deal with the value as you intended.

i.e.

lcd.write((byte) value);

This explicit cast tells the compiler that "value" is a byte value (really an unsigned char) so that
there is no confusion.

This will allow using the naked constant 0 to work.
i.e.

lcd.write((byte) 0);

--- bill

oK thank you very much now it is working good and I understand all
Thanks you again