![]() RS-232 uses voltage levels that will damage Arduino digital pins, so you will need to obtain an RS-232 to TTL adapter to use it. These usually have a nine-pin connector, and an adapter is required to use them with the Arduino. Some serial devices use the RS-232 standard for serial connection. The Adafruit CP2104 Friend (Adafruit part number 3309), Modern Device USB BUB board (Modern Device part MD022X), and FTDI USB TTL Adapter all work well. Some boards, such as the Modern Device Bare Bones Board and the (now-discontinued) Adafruit Boarduino and Arduino Pro, Mini, and Pro Mini, do not have USB support and require an adapter for connecting to your computer that converts TTL to USB. See Recipes 4.13 and 5.11 for examples of voltage dividers. However, if you want to transmit serial data from a 5V to a 3.3V board, you will need to use a level shifter or a voltage divider to avoid damaging the 3.3V board. This means that you can transmit from a 3.3V board and receive the signal on a 5V board in most cases. In most implementations, a 1 can be signaled using less than the device’s high voltage, and 3.3 volts is generally more than enough to signal a 1. ![]() This is referred to as the TTL level because that was how signals were represented in one of the first implementations of digital logic, called Transistor- Transistor Logic (TTL). Using a device’s low voltage (generally 0 volts) to signify 0 and a high voltage (3.3 or 5 volts in the case of Arduino) to signify 1 is very common. If you want to talk to multiple devices using serial communications, either you need more than one serial port or you’ll need to use software serial to emulate a serial port using Arduino pins (see “Emulate Serial Hardware with Digital Pins”). Your computer can also use the serial link to interact with certain sensors or other devices connected to Arduino. Your Arduino sketch can use the serial port to indirectly access (usually via a proxy program written in a language like Processing or Python) all the resources (memory, screen, keyboard, mouse, network connectivity, etc.) that your computer has. ![]() You can use the drop-down to the left of the baud rate to automatically send a newline (ASCII character 10), carriage return (ASCII character 13), a combination of newline and carriage return (“Both NL & CR”), or no terminator (“No line ending”) at the end of each message. The default rate of 9,600 bits per second is fine for many cases, but if you are working with a device that needs a higher speed, you can pass a number higher than 9,600 to Serial.begin(). Make sure to set it to whatever value you use with Serial.begin(). You can set the speed at which data is transmitted (the baud rate, measured in bits per second) using the drop-down box on the bottom right. Arduino also includes a Serial Plotter that can graph serial data sent from Arduino (see Recipe 4.1). You can also send data from the Serial Monitor to Arduino by entering text in the text box to the left of the Send button. The Arduino IDE (described in Recipe 1.3) provides a Serial Monitor (shown in Figure 4-1) to display serial data sent from Arduino. You can also use an external LCD display to show these messages, but in all likelihood, you’d use I2C or SPI to communicate with that kind of display (see Chapter 13). You can send debug messages from Arduino to the computer and display them on your computer screen or send them to another device such as a Raspberry Pi or another Arduino. Serial communications are also a handy tool for debugging. The recipes here show how you can use that same communication link to send and receive any information between Arduino and your computer or another serial device. The upload process sends data from your computer to Arduino, and Arduino sends status messages back to the computer to confirm the transfer is working. This chapter explains how to send and receive information using this capability.Ĭhapter 1 described how to connect the Arduino USB serial port to your computer to upload sketches. Serial communications provide an easy and flexible way for your Arduino board to interact with your computer and other devices.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |