UART (Universal Asynchronous Receiver/Transmitter) is technically neither; it is the logic protocol itself, but it almost always operates at TTL levels (\(0V\)-\(3.3V/5V\)) inside microcontrollers. It produces raw data, which can then be transmitted via TTL or converted to RS-232 (\(+12V\) to \(-12V\)) for long-distance industrial communication. [1, 2, 3, 4, 5]
Key Differences:
UART (TTL): Used on microcontrollers (Arduino, STM32) and sensors. Idle state is HIGH (\(3.3V/5V\)), and active is LOW (\(0V\)).
RS-232: Used on older PCs and industrial equipment. Uses high bipolar voltages (e.g., \(\pm 12V\)) for long distances and noise immunity.
Compatibility: You must use a MAX232 level shifter to connect a TTL UART to an RS-232 device.
TTL UART (0–Vcc, e.g., 3.3V) is for short-distance communication on a single board.
RS-232 (\(\pm 3V\) to \(\pm 15V\)) is for long-distance, industrial, or legacy communication. [1, 2, 3, 4, 5, 6]
Important: Never connect a TTL UART directly to an RS-232 port, as the higher voltages can damage your microcontroller
This section contains the code explanation for the transmitter, which
performs Serial.write(x). The x is the value that reads from the push
button. The push button, when pressed, becomes high, which means that it
becomes 1. The baud rate set for the communication is 9600. The LEDs
are set here to get the value from the receiver to turn the LED on and
off.
This is the section for the receiving part. Both the receiving and
transmitting codes look the same as the communication is happening in
half-duplex. So the commands send from the transmitter and received at
the receiver by the serial.read() if the value is 1, then the LED turns
on; otherwise, it remains off.
The simulation is made to give the demo, as in the picture it can be
seen that the led on the receiver side is on, which happened by pressing
the button at the transmitter. Similarly, the second figure, displays
that LED is on the transmitter side, in which the button at the receiver
is pressed. On pressing the button, the value becomes 1, which means
that the transmitted value is 1, while without pressing the button, the
value is 0.