Pages: [1]   Go Down
Author Topic: Custom Characters example question  (Read 529 times)
0 Members and 1 Guest are viewing this topic.
Bryan, Ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried to compile the custom characters example that comes with the arduino program.  I get the error call of overloaded \write('int') is ambiguous. If i change the 0 to a 1 in this line   lcd.write(0); it compiles.

I tried the code from this post
 
Code:
#include  <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// ^2
byte newChar1[8] = {
  B01100,
  B10010,
  B00100,
  B01000,
  B11110,
  B00000,
  B00000,
  B00000
};
 
// (C)
byte newChar2[8] = {
  B11111,
  B10001,
  B10101,
  B10111,
  B10101,
  B10001,
  B11111,
  B00000
};
 
// (R)
byte newChar3[8] = {
  B11111,
  B10001,
  B10101,
  B10001,
  B10011,
  B10101,
  B11111,
  B00000
};
 
// TM
byte newChar4[8] = {
  B01110,
  B00100,
  B00100,
  B00000,
  B01010,
  B10101,
  B10101,
  B00000
};
 
int i = 0;
 
void setup()
{
  lcd.createChar(0, newChar1);
  lcd.createChar(1, newChar2);
  lcd.createChar(2, newChar3);
  lcd.createChar(3, newChar4);
  lcd.begin(16, 2);
 
  for(int n = 0; n < 4; n++)
  {
    lcd.setCursor(n,0);
    lcd.write(n);
  }
}
 
void loop()
{
 
}

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

and it compiles, whats the difference
code from example
Code:
/*
  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 <heart> 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
 https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde
 
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 
 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);           //******  This is where the error shows up ******
  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);
}


Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4389
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and it compiles, whats the difference
We ran into what I think was a similar problem a few weeks ago and it has something with how the compiler deals with a '0' (which is the address needed to access the first custom character).

Try substituting a '8' instead of '0' when you are dealing with displaying the first custom character.  Sorry, I'm illiterate in 'C' so I can't tell you exactly how to do that.

I'll see if I can find that previous forum topic.

[Edit] Well that didn't take long, here it is:  --> http://arduino.cc/forum/index.php/topic,140917.0.html


Don
« Last Edit: February 03, 2013, 05:41:05 pm by floresta » Logged

Bryan, Ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using eight does work.  I'm a little surprised that an example that came with the arduino program wouldn't compile.  and it works in the other code.
thank's for the info.
Logged

Bryan, Ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I also tried
int n=0;
lcd.write(n);
that works

lcd.write(0);
doesn't work
Logged

Offline Offline
Newbie
*
Karma: 3
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  lcd.write((uint8_t)0);  // add uint8_t when calling zero
Logged

That little black caterpillar you just stepped on will set you back a few bucks....

Pages: [1]   Go Up
Jump to: