The board and terminal are probably not using the same baud rate. Check the bottom right corner of the Arduino Serial Terminal and make sure it is set to 9600.
Serial Data
Serial communication works by sending the entire data stream one bit at a time. This is in contrast to the standard parallel port which sends one byte at a time. Both devices need to know at what speed the data is being sent. Furthermore, both devices need to be operating at the same speed. This is called the baud rate.
Baud Rate
Baud really just means pulses per second. In the context of serial communication, it means how many bits are transmitted per second. One of the most common values is 9600, but there are other common ones which are factors or multiples of 9600. It doesn't really matter, though, as long as both devices operate at the same speed.
If I'm sending you messages faster than you are getting them, you lose data. If I am sending you messages slower than you are receiving them, you get nonsense mixed in with what I sent you.
Data, Parity, Stop bits
If you look at the documentation for begin()
, you'll see it can take two parameters:
Serial.begin(speed)
Serial.begin(speed, config)
Hopefully you understand speed now, it is the bits per second at which the Arduino will communicate.
The second parameter, config
, lets you configure some other things about the serial data transmission. These are the Data, Parity, and Stop bits. You'll see on the page it has values like 5N1
, 6N1
and SERIAL_8N1 (the default)
The first number represents how many data bits. The second character tells you what kind of parity bit there is. E
for even parity, O
for odd parity, or N
for no parity. The third number tells you how many stop bits.
So really, with 8N1, we have 10 bits being sent for each 8 bits of "your" data. 1 start bit, 8 data bits, and 1 stop bit.
Anyway, both sides need to agree on this information as well as the speed. The Arduino Serial Terminal doesn't give you the option of changing these settings, but others do, so you'll need to be sure all of these configuration settings are the same.
More info on wiki: Asynchronous serial communication