Print text and int value

Hello ,
I am trying to do this

uint8_t map Offset = 0;
 EEPROM.get(0, mapOffset);    //EEPROM.get(start address, variable);
 Serial.println("EEprom Val = " + mapOffset);

I am getting no errors on build. Do not get anything on the RS232 termail screen
Ray.

The simplest way is

 Serial.print("EEprom Val = ");
 Serial.println(mapOffset);

Which Arduino board are you using ?
I ask because some boards support other ways of doing it in a single statement. What data type is mapOffset ?

Thank you that worked.
I am using the Nano Maker

Using that board the method of printing several things (text or variables) in a single line of code is not available. There is a way of doing it in 3 lines if there are multiple variables and/or strings to print but I would advise you to keep it simple

If you need to print a combination of text and variables at multiple points in the sketch then you could consider writing a function to do it and calling that with the values to be printed as function parameters

ohh ok :+1:

Nor should you - it's perfectly valid, if a little unsafe.
Try setting "mapOffset" to, say, 7, and see what happens :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.