4
Prints out byte values in all possible formats:
6
* as ASCII-encoded decimal, hex, octal, and binary values
8
For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
10
The circuit: No external hardware needed.
17
<http://www.zambetti.com>
23
// prints title with ending line break
24
Serial.println("ASCII Table ~ Character Map");
27
// first visible ASCIIcharacter '!' is number 33:
29
// you can also write ASCII characters in single quotes.
30
// for example. '!' is the same as 33, so you could also use this:
35
// prints value unaltered, i.e. the raw binary version of the
36
// byte. The serial monitor interprets all bytes as
37
// ASCII, so 33, the first number, will show up as '!'
38
Serial.print(thisByte, BYTE);
40
Serial.print(", dec: ");
41
// prints value as string as an ASCII-encoded decimal (base 10).
42
// Decimal is the default format for Serial.print() and Serial.println(),
43
// so no modifier is needed:
44
Serial.print(thisByte);
45
// But you can declare the modifier for decimal if you want to.
46
//this also works if you uncomment it:
48
// Serial.print(thisByte, DEC);
51
Serial.print(", hex: ");
52
// prints value as string in hexadecimal (base 16):
53
Serial.print(thisByte, HEX);
55
Serial.print(", oct: ");
56
// prints value as string in octal (base 8);
57
Serial.print(thisByte, OCT);
59
Serial.print(", bin: ");
60
// prints value as string in binary (base 2)
61
// also prints ending line break:
62
Serial.println(thisByte, BIN);
64
// if printed last visible character '~' or 126, stop:
65
if(thisByte == 126) { // you could also use if (thisByte == '~') {
66
// This loop loops forever and does nothing
71
// go on to the next character