/* ASCII table Prints out byte values in all possible formats: - as raw binary values - as ASCII-encoded decimal, hex, octal, and binary values For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII The circuit: No external hardware needed. created 2006 by Nicholas Zambetti modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. https://docs.arduino.cc/built-in-examples/communication/ASCIITable/ */ #define DEBUG Stream* debugPtr = NULL; // no debug to start with void setup() { //Initialize Serial1 if debugging, else Serial #ifdef DEBUG Serial1.begin(9600); debugPtr = &Serial1; #else Serial.begin(9600); debugPtr = &Serial; #endif // wait 5secs to allow opening of monitor to see initial output if (debugPtr) { for (int i = 10; i > 0; i--) { debugPtr->print(i); debugPtr->print(' '); delay(500); } debugPtr->println(); } // prints title with ending line break if (debugPtr) { debugPtr->println("ASCII Table ~ Character Map"); } } // first visible ASCIIcharacter '!' is number 33: int thisByte = 33; // you can also write ASCII characters in single quotes. // for example, '!' is the same as 33, so you could also use this: // int thisByte = '!'; void loop() { // prints value unaltered, i.e. the raw binary version of the byte. // The Serial Monitor interprets all bytes as ASCII, so 33, the first number, // will show up as '!' if (debugPtr) { debugPtr->write(thisByte); } // prints value as string as an ASCII-encoded decimal (base 10). // Decimal is the default format for debugPtr->print() and debugPtr->println(), // so no modifier is needed: if (debugPtr) { debugPtr->print(", dec: "); debugPtr->print(thisByte); debugPtr->print(", hex: "); debugPtr->print(thisByte, HEX); debugPtr->print(", oct: "); debugPtr->print(thisByte, OCT); debugPtr->print(", bin: "); debugPtr->println(thisByte, BIN); } // if printed last visible character '~' or 126, stop: if (thisByte == 126) { // you could also use if (thisByte == '~') { // This loop loops forever and does nothing while (true) { continue; } } // go on to the next character thisByte++; }