Asciitable: Demonstrates the advanced function of the Arduino serial output

Source: Internet
Author: User

Original Address-https://www.arduino.cc/en/Tutorial/ASCIITable

ASCII character tabulation

This example shows the Advanced serial printing function, which can generate a corresponding table of characters and ASCII values in the Arduino software (IDE) serial monitor, and the values are displayed in decimal, 16 binary, octal and binary respectively. For more information on ASCII characters, refer to asciitable.com.

Hardware requirements

Arduino or Genuino Development Board

Circuit

No, but the development board must be connected to the computer via a serial port or USB port.

Code

After the serial port is connected on the setup (), the program will print the ASCII table one line at a time until the last printable character. After printing is complete, the device enters the dead loop state of the while structure. Shutting down and opening the Aruino software (IDE) will cause the board to reboot and restart the program.

/* The ASCII table outputs byte values in all possible formats: * Simple binary values * ASCII-encoded decimal, 16 binary, octal, and binary forms to learn more about ASCII, see http://www.asciitable.com and/HTTP EN.WIKIPEDIA.ORG/WIKI/ASCII Circuit: No external circuitry is required. Write Time: 2006Nicholas Zambetti updated: April 9, 2012 updated by: Tom Igoe translation: Suzhou and Hangzhou translation Date: December 14, 2016 This sample code is advertised on the public network .< http://www.zambetti.com  > */void Setup () {//Initialize the serial port and wait for ports to open: Serial.begin (9600); while (! Serial) {;//wait for serial connection.  Using local USB port eloquence is required. }//Output title serial.println with carriage return symbol ("ASCII Table ~ Character Map");} The first visible ASCII character "!" is the number 23:int Thisbyte = 33;//You can also write ASCII characters in single quotes. For example the character "!" The ASCII value is 33, so you can also write://int thisbyte = '! '; void Loop () {//outputs a numeric value, such as a simple binary form of a character.  The serial monitor displays all bytecode as ASCII characters,//So the first number 33 will display '! '.  Serial.write (Thisbyte);  Serial.print (", Dec:");  Outputs a numeric value (decimal) in ASCII-encoded decimal characters.  The decimal number is the default format for Serial.print () and serial.println () and therefore does not need to be changed: Serial.print (Thisbyte);  Of course, if you'd like, you can also declare the output in decimal format.  If you remove the comment from the following sentence and the effect above is the same://Serial.print (Thisbyte, DEC);  Serial.print (", Hex:");  Output hexadecimal format string (hex): Serial.print (Thisbyte, hex); Serial.prInt (", Oct:");  Output octal format string (octal);  Serial.print (Thisbyte, OCT);  Serial.print (", Bin:");  Output binary form of string (binary)//output carriage return line: serial.println (Thisbyte, BIN); If the last visible character ' ~ ' or 126 is output, stop: if (thisbyte = = 126) {//You can also use if (Thisbyte = = ' ~ ') {//This loop has been circulating and nothing is done while (true)    {continue; }}//continue next character thisbyte++;}
Output results
ASCII Table ~ Character map!, dec:33, hex:21, oct:41, bin:100001 ", dec:34, Hex:22, oct:42, bin:100010#, dec:35, H Ex:23, oct:43, bin:100011$, dec:36, hex:24, oct:44, bin:100100%, dec:37, hex:25, oct:45, Bin:100101&amp, Dec:  Hex:26, oct:46, bin:100110 ', dec:39, hex:27, oct:47, bin:100111 (, dec:40, hex:28, oct:50, bin:101000), Dec: Hex:29, oct:51, bin:101001*, dec:42, hex:2a, oct:52, bin:101010+, dec:43, hex:2b, oct:53, bin:101011, Dec : hex:2c, oct:54, bin:101100-, dec:45, hex:2d, oct:55, bin:101101, dec:46, hex:2e, oct:56, bin:101110/, de c:47, hex:2f, oct:57, bin:1011110, dec:48, hex:30, oct:60, bin:1100001, dec:49, hex:31, oct:61, bin:1100012, D Ec:50, hex:32, oct:62, bin:1100103, dec:51, hex:33, oct:63, bin:1100114, dec:52, hex:34, oct:64, bin:1101005,  dec:53, hex:35, oct:65, bin:1101016, dec:54, hex:36, oct:66, bin:1101107, dec:55, hex:37, oct:67, bin:1101118, Dec:56, hex:38, Oct:bin:1110009, dec:57, hex:39, oct:71, bin:111001:, dec:58, hex:3a, oct:72, bin:111010, Dec:59, hex:3b, Oct: Bin:111011&lt, Dec:60, hex:3c, oct:74, bin:111100=, dec:61, Hex:3d, oct:75, Bin:111101>, dec:62, Hex:3 E, oct:76, bin:111110, dec:63, hex:3f, oct:77, bin:111111@, dec:64, hex:40, oct:100, bin:1000000a, dec:65, Hex : oct:101, bin:1000001b, dec:66, hex:42, oct:102, bin:1000010c, dec:67, hex:43, oct:103, bin:1000011d, Dec: Hex:44, oct:104, bin:1000100e, dec:69, hex:45, oct:105, bin:1000101 ...
See Also

    • Increment, + +
    • while ()
    • Serial ()
    • Dimmer-Move the mouse to change the brightness of the LED light.
    • Graph-transmits data to the computer and draws graphics in the process.
    • Midi-traversing transmits audio information.
    • Multiserialmega-Use the two available serial ports of Arduino and Genuino Mega.
    • Physicalpixel-Send data to your development Board, using programs or MAX/MSP to switch.
    • readasciistring-resolves a comma-delimited numeric string to control the brightness of the LEDs.
    • Serialcallresponse-Send multiple values in question-and-answer mode.
    • SERIALCALLRESPONSEASCII-Send multiple values in question-and-answer mode and encode them in ASCII code before sending.
    • Serialevent-Demonstrates how to use the serialevent() function.
    • Virtualcolormixer-use programs or MAX/MSP to send multiple values from Arduino to your computer.


Final version Edit 2015/07/28 SM

QQ Group

Welcome to our extended family Click to join the hard hit Alliance Arduino group number 8580606

Translation: Hard-hit Alliance translation group-Suzhou and Hangzhou
Audit: Hard-hit Alliance translation Group technical Language audit-magic conch, lepton-, Chengdu Jie

Asciitable: Demonstrates the advanced function of the Arduino serial output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.