Go Down

Topic: call of overloaded 'write (int)' is ambigiuos (Read 516 times) previous topic - next topic

i_luv_arduino

When I try to compile I get this error
"call of overloaded 'write (int)' is ambigiuos"
Here is the parts of my code I think the error is in:
Code: [Select]
#include <LiquidCrystal.h>

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


byte paddleup[8] = {
  0b10000,
  0b10000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

byte paddletwo[8] = {
  0b00000,
  0b00000,
  0b10000,
  0b10000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

byte paddleone[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b10000,
  0b10000,
  0b00000,
  0b00000
};

byte paddledown[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b10000,
  0b10000

};
byte ballone[8] = {
  0b00000,
  0b00100,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

byte balltwo[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00100,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

byte ballthree[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00100,
  0b00000,
  0b00000
};
byte ballfour[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00100
};






void setup() {
  // set up the LCD's number of columns and rows:
  lcd.createChar(0, ballone);
  // create a new character
  lcd.createChar(1, balltwo);
  // create a new character
  lcd.createChar(2, ballthree);
  // create a new character
  lcd.createChar(3, ballfour); 
  // create a new character
  lcd.createChar(4, paddleup);
  // create a new character
  lcd.createChar(5, paddletwo);
  // create a new character
  lcd.createChar(6, paddleone);
  // create a new character
  lcd.createChar(7, paddledown); 
 

And the other part:
Code: [Select]
lcd.setCursor(6, 1);
lcd.write(0);
delay(100);
if (pushButton == HIGH); {
  x = x+1;
  }

pYro_65

It is saying it needs more information.

Code: [Select]
lcd.write(0);

This can match a couple of write methods, provide more context by casting it to what you desire ( have a look at the lcd library and what overloads it provides ).

Code: [Select]
lcd.write( ( byte ) 0 );
lcd.write( int(0) );
lcd.write( 0.0f );


Forum Mod anyone?
https://arduino.land/Moduino/

johnwasser

I think the problem is that 0 can be interpreted as either a byte:
Code: [Select]

virtual size_t LCD::write(uint8_t)


or a null character pointer:
Code: [Select]

size_t Print::write(const char*)


Instead, use '\0' which is a character constant or cast it: (uint8_t)0
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

i_luv_arduino


i_luv_arduino


pYro_65

yes, '\0' is a null character, there is a number of escape characters:

Quote
\' \" \? \\
\a \b \f \n \r \t \v


search google for a full explanation.
Forum Mod anyone?
https://arduino.land/Moduino/

AWOL

Quote
so I can use '/0'?

No, you cannot - it is a multicharacter literal consisting of the characters '/' and '0'.
You can use '\0'.

OP - stop locking or deleting your threads.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy