/*
Forum: https://forum.arduino.cc/t/ascii-representation-of-1234/1198200
Wokwi: https://wokwi.com/projects/383546889615798273
Be aware that aNumber in printASCII() is declared here as int!
See the range of integer variables:
https://www.arduino.cc/reference/en/language/variables/data-types/int/
For other types/ranges have a look at:
https://forum.arduino.cc/t/itoa-function/975977
*/
void setup() {
Serial.begin(115200);
Serial.println("Print ASCII");
Serial.println();
printASCII(1234);
printASCII(32567);
}
void loop() {
}
void printASCII(int aNumber) {
char buf[40];
itoa(aNumber,buf,DEC);
Serial.println(buf);
for (int i = 0;i<strlen(buf);i++){
Serial.print(buf[i],HEX);
Serial.print(" ");
}
Serial.println();
}