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.begin(9600);
Serial.print("Sanity Check\n");
uint16_t num = 12000;
Serial.print("\nNumber: " + String(num) + "\n");
delay(3000);
}
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?