O'Reilly logo

Arduino Sketches: Tools and Techniques for Programming Wizardry by James A. Langbridge

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER5

Serial Communication

After reading this chapter, you will be familiar with the following functions:

  • if (Serial)
  • available()
  • begin()
  • end()
  • find()
  • findUntil()
  • parseFloat()
  • parseInt()
  • peek()
  • print()
  • println()
  • read()
  • readBytes()
  • readBytesUntil()
  • setTime-out()
  • write()

The following hardware is required to complete the activities and examples presented in this chapter:

  • Arduino Uno
  • USB Cable

The code download for this chapter is found at http://www.wiley.com/go/arduinosketches on the Download Code tab. The code is in the Chapter 5 folder and the filename is chapter5.ino.

Introducing Serial Communication

The original IBM PC, introduced in 1981, came with two serial ports, physical connectors allowing the computer to connect to devices or another computer via the RS-232 protocol. For most people, this was the beginning of the serial port, but in reality, it started much earlier. Early computers had serial ports, and they have even been used on mainframes. They have been in use almost since the beginning of microprocessor-based computers.

The word serial comes from the way data is transmitted; serial devices send bits one at a time on a single wire. This is something that you have seen before; it is like a telephone call. Both users pick up the telephone and a single wire connects them together. Both users can talk at the same time (even if it is considered polite to listen while the other person talks), and words are sent one at a time. Both sides are free to start talking ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required