Serial.print problems.

Hey everyone,

I'm having a problem with the Serial.print function. When I want to send anything other than a string, an error comes up. For example:

Serial.print("This is a string");
is OK.

Serial.print(10);
comes up with an error message
undefined reference to 'Print::print(int, int)'

I'm using Code::Blocks and not the Arduino IDE because of the ease of handling libraries. All the core libraries are in the program.

int main(){

    init();
    Serial.begin(19200);
    Wire.begin();

    while(1){
        delay(1000);
        Serial.print("a");
        Serial.print(10);
    }
}

When printing integers, the second (optional) argument is the base numbering system (BIN, HEX, DEC, etc.). It appears as though Code::Blocks is not recognizing that the 2nd argument is optional. It defaults to DEC, so just supply the 2nd argument.

I tried that. Regardless of what 2nd arguments I enter or what I use as the first argument, an 'undefined reference to ...' error appears. Quite frustrating. Why is it that a character string works, but nothing else?

Does the message change as you try different arguments? If the message always refers to the same function (Print::print(int, int)) then I think the problem is with Code::Blocks.

You might try something like:

int val = 10;
int base = 10;
Serial.print(val, base);

See if that is something the compiler likes.