Pages: [1]   Go Down
Author Topic: can't complie CustomCharacter example sketch- totally unedited?  (Read 1417 times)
0 Members and 1 Guest are viewing this topic.
South UK
Offline Offline
God Member
*****
Karma: 5
Posts: 585
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all, I am trying to create some custom characters, I could not get it to work in my code so to try and go back to square one I am trying out the built in example CustomCharacter but won't compile and comes up with the same error I used to get? Is there something wrong with my version of the arduino software or something?

Code..
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);
  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);
}


errors...
Quote
CustomCharacter.cpp: In function 'void setup()':
CustomCharacter:114: error: call of overloaded 'write(int)' is ambiguous
K:\Arduino\arduino-1.0\libraries\LiquidCrystal/LiquidCrystal.h:82: note: candidates are: virtual size_t LiquidCrystal::write(uint8_t)
K:\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note:                 size_t Print::write(const char*)
« Last Edit: March 06, 2012, 08:10:09 pm by dtokez » Logged

Offline Offline
Edison Member
*
Karma: 48
Posts: 1614
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't used the lcd library and I don't know what the code is trying to do but try changing each occurrence of this kind of statement:
Code:
lcd.write(0);

to this:
Code:
lcd.write('0');

Pete
Logged

Where are the Nick Gammons of yesteryear?

South UK
Offline Offline
God Member
*****
Karma: 5
Posts: 585
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, that complies but just displays the actual number instead of the char i.e lcd.write('3'); just writes the number 3?

Maybe there is a problem with the example sketch?
Logged

Offline Offline
Edison Member
*
Karma: 48
Posts: 1614
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AHA. Now I understand. The way around it is to use, for example,
Code:
lcd.write((uint8_t)0);

Pete
Logged

Where are the Nick Gammons of yesteryear?

South UK
Offline Offline
God Member
*****
Karma: 5
Posts: 585
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks I will try that later, surely the example sketch built into the Arduino IDE should work without any modification?
Logged

Offline Offline
Edison Member
*
Karma: 48
Posts: 1614
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It may be caused by the difference between libraries and examples created for V0.23 or earlier and the V1.0 IDE.

Pete
Logged

Where are the Nick Gammons of yesteryear?

South UK
Offline Offline
God Member
*****
Karma: 5
Posts: 585
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that's great it works fine now smiley

is there a way to tell the people in charge that the example sketch needs attention?
Logged

Deep South (Of England)
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks so much for this info guys smiley

I have been pulling my hair out trying to fix this same issue.

Works perfectly now.

Cheers

Andy R (AKA G1UUP)
Logged

Barcelona
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I just had the same issue with that example...

I fixed by increasin 1 up the assigned numbers for each customized character, that means, leaving 0 unused.
So, first customized character in my case is 1.

Obviously, I had all refences changed to fit the proper character numbers.

Cheers,
Rafa.
Logged

Pages: [1]   Go Up
Jump to: