ASCII Table using Arduino

Demonstrates the advanced serial printing functions by generating a table of characters and their ASCII values in decimal, hexadecimal, octal, and binary. For more on ASCII, seeΒ asciitable.com

Circuit

image developed usingΒ Fritzing. For more circuit examples, see theΒ Fritzing project page

None, but the Arduino has to be connected to the computer.

Code

/*
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.
<http://www.zambetti.com>
*/
voidΒ setup()Β {
//Initialize serial and wait for port to open:
Serial.begin(9600);
whileΒ (!Serial)Β {
;Β // wait for serial port to connect. Needed for Leonardo only
}
// prints title with ending line break
Serial.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 ‘!’
Serial.write(thisByte);

[box color=”#985D00″ bg=”#FFF8CB” font=”verdana” fontsize=”14 ” radius=”20 ” border=”#985D12″ float=”right” head=”Major Components in Project” headbg=”#FFEB70″ headcolor=”#985D00″]

Hardware Required

  • Arduino Board

[/box]

For more detail:Β ASCII Table using Arduino

About The Author

Scroll to Top