Serial Terminals for Linux and Mac OS X
Linux and Mac users can use the
screen
command to communicate with the
Arduino on a serial port. Check which serial port the Arduino is connected
to in the IDE’s Tools > Board menu. Then run a command like this (with an
older board the name of the serial port might be something like
/dev/tty.usbserial-
A9007LUY
, and on Linux systems it might be
/dev/ttyUSB1
or something similar):
$ screen /dev/tty.usbmodem24321 9600
The
screen
command expects the name of the serial port and the baud rate to
be used. To quit the
screen
command, press Ctrl-a followed by k. (On some
systems it’s Ctrl-a followed by Ctrl-k.)
We can now communicate with the Arduino, and this has great implications:
whatever is controlled by the Arduino can also be controlled by your computer,
and vice versa. Switching LEDs on and off isn’t too spectacular, but try to
imagine what’s possible now. You could move robots, automate your home,
or create interactive games.
Here are some more important facts about serial communication:
• The Arduino Uno’s serial receive buffer can hold up to 64 bytes. When
sending large amounts of data at high speed, you have to synchronize
sender and receiver to prevent data loss. Usually, the receiver sends an
acknowledgment to the sender whenever it is ready to consume a new
chunk of data.
Chapter 2. Creating Bigger Projects with the Arduino • 34
report erratum • discuss
www.it-ebooks.info