Project 2.01 Hello World
This is our first demonstration of the serial monitor. We program the Arno the send messages back to the user. The messages are viewed in the serial monitor.
Concepts: Serial object
Circuits: none
Concepts: Serial object
Circuits: none
This project uses the Serial object for communication. You must create an instance of this object in the loop() block if you want to use serial communication:
Serial.begin(9600);
The value in parentheses is a holdover from older Arduino boards. In the past, we used to set the baud rate (9600 was a common rate and we still use it out of habit). The number in parentheses doesn’t matter with the Arno, which uses direct USB communication, but a number is still required by the compiler to avoid an error. For older Arduino boards like the Uno or Duemillanove, the baud rate set in the Serial.begin statement must match the baud rate set in the serial monitor window of the IDE. The baud rate is set in the serial monitor by a pull-down tab in the lower-right corner of its window. Again, it doesn’t matter for the Arno or other boards based on the 32U4 chip.
The Serial.print and Serial.println commands both output their contents to the serial monitor. Serial.print doesn’t start a new line; the next text comes out on the same line. These two commands print their output to the same line:
Serial.print("Counter = ");
Serial.println(counter);
However, the second command starts a new line so that when we we reach the top of the loop() block again, the output begins on a new line.
Serial.begin(9600);
The value in parentheses is a holdover from older Arduino boards. In the past, we used to set the baud rate (9600 was a common rate and we still use it out of habit). The number in parentheses doesn’t matter with the Arno, which uses direct USB communication, but a number is still required by the compiler to avoid an error. For older Arduino boards like the Uno or Duemillanove, the baud rate set in the Serial.begin statement must match the baud rate set in the serial monitor window of the IDE. The baud rate is set in the serial monitor by a pull-down tab in the lower-right corner of its window. Again, it doesn’t matter for the Arno or other boards based on the 32U4 chip.
The Serial.print and Serial.println commands both output their contents to the serial monitor. Serial.print doesn’t start a new line; the next text comes out on the same line. These two commands print their output to the same line:
Serial.print("Counter = ");
Serial.println(counter);
However, the second command starts a new line so that when we we reach the top of the loop() block again, the output begins on a new line.