I am using an Arduino simulator on www.tinkercad.com (a seemingly nice free product from Autodesk). Working on conversion of an integer to a 16 bit binary string for output to a DAC, but unfortunately even at the first step I am getting unexpected behavior.

void setup()
  pinMode(13, OUTPUT);
  Serial.print("Sanity Check\n");
  uint16_t num = 12000;
  Serial.print("\nNumber: " + String(num) + "\n");

Surprisingly the above code gave the following output:

Sanity Check

Number: 12222

Is there something I am doing wrong, or something wrong with the simulator? The error seems to crop up with any value over 10000. 10001, 10002, 10003 all print as 10000. 11000, 11001, 11002, 11003 all print as 11111. etc, etc. What could be going on?

  • My Uno prints “Number: 12000”. Mar 23, 2018 at 19:34

2 Answers 2


Bug. No other explanation. Real hardware (Arduino Uno) prints 12000.

Even the debugger tells me that the value of that variable is 12000.



Number: 12222 
12222 something 

Most interestingly if you Serial.println() the number, it is outputted correctly. The bug must be in the constructor of the String object, as demonstrated by the "test" String. This bug also occurs on other data types, e.g. int.

If you only use direct Serial.print[ln] calls you should be able to workaround that bug.


Tinkercad is (was) a very good simulator but it has stopped updates. Here is the output from the free Arduino simulator from here

This project is used for the below screenshot

enter image description here

Here is an article pointing some more features of the simulator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.