mak237 Posted June 18, 2014 Report Share Posted June 18, 2014 I'm currently trying to work with a device that expects specific values to be sent to it over serial. When I try to send a value of 0 over serial I get the error "call of overloaded 'write(int)' is ambiguous". An example of this is below:void setup(){ Serial.begin(9600);}void loop(){ Serial.write(0);}On the other hand, when I set a variable to 0 and then write that variable out over serial it sends the value out without a problem. An example of the working variant is here:int number;void setup(){ Serial.begin(9600); number = 0;}void loop(){ Serial.write(number);}It's also worth noting that it seems to also do this in the actual Arduino IDE in addition to ZAP.Is this functioning as intended or is this a bug? Link to comment Share on other sites More sharing options...
hamster Posted June 18, 2014 Report Share Posted June 18, 2014 The compiler can't guess what data type 0 should be - char, int, short, signed, unsigned...? Try casting it: Serial.Write((int)0)); Or use a char constant: Serial.Write('0')); Or a char array: Serial.Write("0")); Link to comment Share on other sites More sharing options...
mak237 Posted June 19, 2014 Author Report Share Posted June 19, 2014 Thanks, I didn't know if this was how it was supposed to work or not. Link to comment Share on other sites More sharing options...
OmniTechnoMancer Posted June 20, 2014 Report Share Posted June 20, 2014 Well its probably the char* and int overloads causing it as 0 could be either, note that you need to use '\0' if you want a character with value zero sent on the serial rather than the digit 0 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.