Hardware Reference
In-Depth Information
ChangingDataTypeRepresentations
The Serial.print() and Serial.println() functions are fairly intelligent when
it comes to printing out data in the format you are expecting. However, you have
options for outputting data in various formats, including hexadecimal, octal,
and binary. Decimal-coded ASCII is the default format. The Serial.print()
and Serial.println() functions have an optional second argument that speci-
fies the print format. TableĀ 6-1 includes examples of how you would print the
same data in various formats and how it would appear in your serial terminal.
Table 6-1: Serial Data Type Options
DATA TYPE
EXAMPLE CODE
SERIAL OUTPUT
Decimal
Serial.println(23);
23
Hexadecimal
Serial.println(23, HEX);
17
Octal
Serial.println(23, OCT)
27
Binary
Serial.println(23, BIN)
00010111
TalkingtotheArduino
What good is a conversation with your Arduino if it's only going in one direc-
tion? Now that you understand how the Arduino sends data to your computer,
let's spend some time discussing how to send commands from your computer
to the Arduino. You've probably already noticed that the Arduino IDE serial
monitor has a text entry field at the top, and a drop-down menu at the bottom.
FigureĀ 6-8 highlights both.
Figure 6-8: Screenshot of serial terminal highlighting text entry field and Line Ending
Options drop-down menu
Search WWH ::




Custom Search