Software serial- Encoding

So, on the softwareSerial reference page, it lists examples such as this:

serial.print(analogValue, DEC);    // print as an ASCII-encoded decimal

But, when I try and do this I get an error that says:

no matching function for call to 'SoftwareSerial::print(String&,int)'

Anyone know what is going on here?

I think I may have just answered my own question. It seems like this doesn't work with Strings?

Well you can't print out a String in a certain base because Strings don't have bases. Only numbers have bases. When you convert your number to a String, you set the base.

Or, better yet, don't use Strings at all and just do softserial.print(45); or softserial.print(94, HEX);

But it didn’t complain with a char. Why is that?

But it didn't complain with a char. Why is that?

We'd need to see the exact code.

Fredjikrang: But it didn't complain with a char. Why is that?

Because a char is the same as an unsigned byte. You can treat a char as a number, like this:

char myHeight = 66; // 66 inches

// I want to be taller char += 2;

A "string" is an array of characters:


Note that the string above is with a lower case s. Then there is String (with upper case S) which is a class. Neither of these can be treated like an integer type.

A char is a type of number. A character array (char x[] or char* or "stuff") might be able to be converted to a number since it's a pointer, but you wouldn't get out what you expect (you'd see the address at which the array is stored)

Okay, thanks!