<div class="woocommerce-tabs wc-tabs-wrapper" style="box-sizing: border-box; clear: both; margin-bottom: 50px; font-family: &quot;Open Sans&quot;, Helvetica, Arial, sans-serif; font-size: 14px; background-color: #f5f5f5;">
   <div class="woocommerce-Tabs-panel woocommerce-Tabs-panel--description panel entry-content wc-tab" id="tab-description" role="tabpanel" aria-labelledby="tab-title-description" style="box-sizing: border-box; margin: 0px 0px 2em; padding: 10px 15px 15px; width: 847.5px; border: 1px solid rgb(236, 236, 236); background: rgb(255, 255, 255);">
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">DESCRIPTION</h2>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The MAX485 TTL to RS-485 Interface Module allows uCs to use the RS-485 differential signaling for robust long distance serial communications.</p>
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;"><span style="box-sizing: border-box; font-weight: bolder;">PACKAGE INCLUDES:</span></h2>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;">MAX485 TTL to RS-485 Interface Module</li>
         </ul>
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;"><span style="box-sizing: border-box; font-weight: bolder;">KEY FEATURES OF MAX485 TTL TO RS-485 INTERFACE MODULE:</span></h2>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;">Use MAX485 Interface chip</li>
         <li style="box-sizing: border-box;">Uses differential signaling for noise immunity</li>
         <li style="box-sizing: border-box;">Distances up to 1200 meters</li>
         <li style="box-sizing: border-box;">Speeds up to 2.5Mbit/Sec</li>
         <li style="box-sizing: border-box;">Multi-drop supports up to 32 devices on same bus</li>
         <li style="box-sizing: border-box;">Red power LED</li>
         <li style="box-sizing: border-box;">5V operation</li>
         </ul>
      <p style="box-sizing: border-box; margin-bottom: 20px;">RS-485 provides for robust serial communications over long distances of up to 1200 meters (4000′) or in electrically noisy environments and is commonly used in industrial environments.&nbsp; It supports up to 2.5MBit/Sec data rates, but as distance goes up, the maximum data rate that can be supported comes down.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">You can think of RS-485 as RS232 on steroids.&nbsp; The data starts out as typical TTL level serial as far as the microcontroller is concerned while the RS-485 module takes care of converting the electrical signals between TTL and the differential signaling used by RS-485.</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Multi-Drop Support for Multiple Devices</h3>
      <p style="box-sizing: border-box; margin-bottom: 20px;">A significant benefit of RS-485 is that it supports multiple devices (up to 32) on the same cable, commonly referred to as ‘multi-drop’.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">This works by passing the bus through each device where it picks off the signal as it passes through as shown below.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">These devices are typically setup in a Master / Slave configuration with one Master and one or more Slave devices.&nbsp; Since they all share the same bus, to avoid conflict the Slave devices only talk when they are asked for something by the Master such as requesting a temperature reading.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><img loading="lazy" class="size-full wp-image-5417 aligncenter" src="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop.jpg" alt="MAX485 Multi-Drop Wiring" width="673" srcset="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop.jpg 673w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop-400x149.jpg 400w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop-350x131.jpg 350w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop-300x112.jpg 300w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Multi-Drop-280x104.jpg 280w" sizes="(max-width: 673px) 100vw, 673px" style="box-sizing: border-box; border: 0px none; vertical-align: middle; height: auto; max-width: 100%; clear: both; display: block; margin: 0px auto;" /></p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Differential Signaling</h3>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The RS-485 uses differential signaling and requires only 2 wires and a common ground.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">Differential signals operate by putting the signal on 1 wire and the inverse of the signal on the other wire.&nbsp; This improves the signals noise immunity and the ability to recover the signal at the far end of the cable as noise tends to couple into both lines equally and therefore cancels out at the receiving end.</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Wiring RS-485</h3>
      <p style="box-sizing: border-box; margin-bottom: 20px;">These two differential data lines are labeled as A &amp; B.&nbsp; On the module, these are available on the screw terminal block as well as the two center pins on that end of the module.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">When connecting the modules together, the wiring is straight through, so A on one end should be connected to A on the other end and B connects to B.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The wires should ideally be twisted pair.&nbsp; Using twisted pair becomes more important for longer runs or where there is a lot of electrical noise.&nbsp; For simple breadboard testing or other short runs, it is not necessary.&nbsp; A common ground is needed, but this can often be provided by the earth ground at each end for shorter runs.&nbsp; Network cable is often used for connecting RS-485 as it provides twisted pair, plus it can provide a ground wire as well.</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Pull-up Resistors</h3>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The module provides four 10K pull-up resistors on the data lines.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">There are two 20K resistors on the A/B differential lines.&nbsp; These pull the lines to a known state when data is not being transmitted.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">Finally there is a single 120 ohm resistor (R7).&nbsp; This resistor goes between the A/B differential lines on each end of the cable to prevent reflections.&nbsp; If using in a multi-drop configuration, the modules on the two ends of the line should keep these resistors.&nbsp; Modules in the middle of the line should have these resistors removed to prevent loading the lines too heavily as shown in the pic above.&nbsp; This requirement can often be ignored when the number of devices is small.</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Module Connections</h3>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The module has two 4-pin headers on the assembly.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><span style="box-sizing: border-box; font-weight: bolder;">1 x 4 Header (Data side)</span></p>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">RO&nbsp;</span>&nbsp;=&nbsp; Receiver Output.&nbsp; Connects to a serial RX pin on the microcontroller</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">RE&nbsp;</span>&nbsp;= &nbsp;Receiver Enable.&nbsp; Active LOW.&nbsp; Connects to a digital output pin on a microcontroller. Drive LOW to enable receiver, HIGH to enable Driver</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">DE&nbsp;</span>&nbsp;= &nbsp; Driver Enable.&nbsp; Active&nbsp; HIGH.&nbsp; Typically jumpered to RE Pin.</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">DI&nbsp; =</span>&nbsp; &nbsp;Driver Input.&nbsp; Connects to serial TX pin on the microcontroller</li>
         </ul>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><span style="box-sizing: border-box; font-weight: bolder;">1 x 4 Header (Output side)</span></p>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">VCC</span>&nbsp;= &nbsp;5V</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">B</span>&nbsp; &nbsp; &nbsp; = &nbsp;Data ‘B’ Inverted Line. Common with the B</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">A&nbsp; &nbsp; &nbsp; =</span>&nbsp; Data ‘A’ Non-Inverted Line.&nbsp; Connects to A on far end module</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">GND</span>&nbsp;= &nbsp;Ground</li>
         </ul>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><span style="box-sizing: border-box; font-weight: bolder;">1 x 2 Screw Terminal Block (Output side)</span></p>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">B&nbsp; &nbsp; &nbsp;</span>&nbsp;= Data ‘B’ Inverted Line. Connects to B on far end module</li>
         <li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: bolder;">A&nbsp; &nbsp; &nbsp;</span>&nbsp;= Data ‘A’ Non-Inverted Line.&nbsp; Connects to A on far end module</li>
         </ul>
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">OUR EVALUATION RESULTS:</h2>
      <p style="box-sizing: border-box; margin-bottom: 20px;">You will need RS-485 on both ends, so typically you will need two of these modules to implement a basic link unless you are trying to interface with a device that already has RS-485 implemented.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">When working with these devices, keep in mind that they are basically just level translators.&nbsp; From the microcontrollers perspective, the functionality is the same as if two RS232 serial ports are connected for communicating between the devices.&nbsp; If there is difficulty in using the devices, they can often be temporarily removed from the setup to see if the issue is with the RS-485 or something more basic in the setup.&nbsp; If they are removed from the setup, the RX/TX lines between the microcontrollers need to be crossed i.e. TX1 to RX2 and RX1 to TX2.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The main tricky part when working with these devices is to ensure that the DE/RE lines are held in the correct state as the data is moved back and forth between the Master and Slave devices.&nbsp; This timing can be affected by the data rates being used.&nbsp; If you are getting garbage transmitted, this is usually the first place to look.<a href="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup.jpg" style="box-sizing: border-box; background-color: transparent; color: #000000; text-decoration-line: none;" target="_blank"><img loading="lazy" class="alignright wp-image-4911 size-medium" src="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup-300x225.jpg" alt="MAX485 Module Test Setup" width="300" srcset="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup-300x225.jpg 300w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup-400x300.jpg 400w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup.jpg 800w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup-768x576.jpg 768w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-Module-Test-Setup-249x187.jpg 249w" sizes="(max-width: 300px) 100vw, 300px" style="box-sizing: border-box; border: 0px none; vertical-align: middle; height: auto; max-width: 100%; float: right; margin: 0px 0px 10px 20px;" /></a></p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The programs below create both a Master device and a Slave device.&nbsp; For this setup, you will need two Arduinos of any type (or other microcontrollers) and two of the RS-485 modules. &nbsp;You will download the Master software to one device and the Slave software to the second device.&nbsp; The programs use the SoftSerial library for communication in order to leave the hardware serial port available for monitoring the data on the Serial Monitor windows of the two Arduinos.&nbsp; If you are using a version of board that has multiple hardware serial ports, you can use one of those instead if you prefer but it is recommend to get the setup up and running as shown first, then start making mods.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">Both devices use the same pins for their soft serial port.&nbsp; Connect as follows from Arduino to RS-485 module on both devices</p>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;">Pin 10 (RX) connects to RO</li>
         <li style="box-sizing: border-box;">Pin 11 (TX) connects to DI</li>
         <li style="box-sizing: border-box;">Pin 3 (CTRL) connects to RE and DE.</li>
         <li style="box-sizing: border-box;">5V connects to VCC</li>
         <li style="box-sizing: border-box;">Gnd connects to Gnd</li>
         </ul>
      <p style="box-sizing: border-box; margin-bottom: 20px;">Connect data lines A to A and B to B between RS-485 modules.&nbsp; You can use either the terminal block or the header pins to make these connections.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">The Master device allows you to type any character in the top portion of the Serial Monitor window and once you press enter, it will send that character to the Slave device.&nbsp; When the Slave&nbsp;<a href="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-%E2%80%93-software.jpg" style="box-sizing: border-box; background-color: transparent; color: #000000; text-decoration-line: none;" target="_blank"><img loading="lazy" class="alignright wp-image-4914 size-medium" src="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-%E2%80%93-software-300x225.jpg" alt="MAX485 TTL to RS-485 Interface Module – software" width="300" srcset="https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-–-software-300x225.jpg 300w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-–-software-400x300.jpg 400w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-–-software.jpg 800w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-–-software-768x576.jpg 768w, https://protosupplies.com/wp-content/uploads/2018/05/MAX485-TTL-to-RS-485-Interface-Module-–-software-249x187.jpg 249w" sizes="(max-width: 300px) 100vw, 300px" style="box-sizing: border-box; border: 0px none; vertical-align: middle; height: auto; max-width: 100%; float: right; margin: 0px 0px 10px 20px;" /></a>receives the character, it will send what it received out to its own Serial Monitor window as well as echo it back to the Master device.&nbsp; Once the Master device receives the character back from the Slave, it will print it out to its own Serial Monitor window.&nbsp; Basically, if you type an ‘a’ and hit ENTER in the top window of the Master device and you see an ‘a’ appear in the bottom window, the command has made a full round trip.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">Note that if you want to use the Serial Monitor Window on both the Master and Slave device at the same time, or program both Arduinos without moving USB cables around and resetting COM ports and Arduino types, &nbsp;you will need to create two instances of the Arduino IDE.</p>
      <p style="box-sizing: border-box; margin-bottom: 20px;">To do that, you just need to open the IDE from the Start menu (or where ever you typically open it) twice.&nbsp; You cannot just open a 2nd window from an existing IDE.&nbsp; &nbsp;Once you have two separate IDEs running, open the Master software in one and the Slave software in the 2nd.&nbsp; Configure both for the COM port and the Arduino type you are using with each window.&nbsp; You will of course also need two USB cables to connect both Arduinos up to your PC at the same time.</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Master RS-485 Device Software</h3>
      <pre style="box-sizing: border-box; overflow: auto; font-family: monospace, monospace; font-size: 1em; padding: 9.5px; margin-top: 0px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; color: #333333; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><span style="box-sizing: border-box; color: #95a5a6;">/*</span><span style="box-sizing: border-box; color: #95a5a6;"> * RS485 Master Software</span><span style="box-sizing: border-box; color: #95a5a6;"> * Exercise the MAX485 Module. &nbsp;This code runs on the first (Master)device.</span><span style="box-sizing: border-box; color: #95a5a6;"> * Use the RS485_Slave_Test software for the second (Slave) device</span><span style="box-sizing: border-box; color: #95a5a6;"> * This uses the SoftSerial.h library which comes with the Arduino IDE</span><span style="box-sizing: border-box; color: #95a5a6;"> * Pins used for the soft serial port are fairly arbitrary and can be changed</span><span style="box-sizing: border-box; color: #95a5a6;"> * as needed. &nbsp;Just redefine them below.</span><span style="box-sizing: border-box; color: #95a5a6;"> */</span><span style="box-sizing: border-box; color: #5e6d03;">#include</span><span style="box-sizing: border-box; color: #434f54;">&lt;</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">SoftwareSerial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #000000;">h</span><span style="box-sizing: border-box; color: #434f54;">&gt;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_RX_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">10</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">//Soft Serial Receive pin</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_TX_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">11</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">//Soft Serial Transmit pin</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">3</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">//RS485 Direction control</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">13</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">RS485_TRANSMIT</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #00979c;">HIGH</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #00979c;">LOW</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #434f54;">// Create Soft Serial Port object and define pins to use</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">SoftwareSerial</span></span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_RX_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_TX_PIN</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #434f54;">// RX, TX</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #434f54;">// &nbsp;Initialization</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #00979c;">void</span><span style="box-sizing: border-box; color: #5e6d03;">setup</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">begin</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">9600</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Start the built-in serial port</span>
 &nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">println</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #005c5f;">"Master Device"</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span>
 &nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">println</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #005c5f;">"Type in upper window, press ENTER"</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span>
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">pinMode</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">OUTPUT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Configure any output pins</span>
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">pinMode</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">OUTPUT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 in receive mode &nbsp;</span>
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">begin</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">9600</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Start the RS485 soft serial port </span><span style="box-sizing: border-box; color: #000000;">}</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #434f54;">// &nbsp;Main</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #00979c;">void</span><span style="box-sizing: border-box; color: #5e6d03;">loop</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;<span style="box-sizing: border-box; color: #5e6d03;">if</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">available</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">)</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// A char(byte) has been entered in the Serial Monitor</span>
 &nbsp;<span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">read</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Read the byte</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_TRANSMIT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 in Transmit mode &nbsp;&nbsp;</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">write</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Send byte to Remote Arduino</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">delay</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">1</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Wait before going back to Receive mode</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 back into Receive mode &nbsp;&nbsp;&nbsp;</span>
 &nbsp;<span style="box-sizing: border-box; color: #000000;">}</span>
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #5e6d03;">if</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">available</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">)</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">//Data from the Slave is available</span>
 &nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">HIGH</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Show activity on LED</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">read</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Read received byte</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">write</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Show on Serial Monitor</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">delay</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">10</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">LOW</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Turn LED back off</span>
 &nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">}</span> &nbsp;
<span style="box-sizing: border-box; color: #000000;">}</span></pre>
      <p style="box-sizing: border-box; margin-bottom: 20px;">&nbsp;</p>
      <h3 style="box-sizing: border-box; line-height: 30px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Slave RS-485 Device Software</h3>
      <pre style="box-sizing: border-box; overflow: auto; font-family: monospace, monospace; font-size: 1em; padding: 9.5px; margin-top: 0px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; color: #333333; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><span style="box-sizing: border-box; color: #95a5a6;">/*</span><span style="box-sizing: border-box; color: #95a5a6;"> * RS485 Slave Software</span><span style="box-sizing: border-box; color: #95a5a6;"> * Exercise the MAX485 Module. &nbsp;This code runs on the second (slave)device.</span><span style="box-sizing: border-box; color: #95a5a6;"> * Use the RS485_Master_Test software for the first (Master) device</span><span style="box-sizing: border-box; color: #95a5a6;"> * This uses the SoftSerial.h library which comes with the Arduino IDE</span><span style="box-sizing: border-box; color: #95a5a6;"> * Pins used for the soft serial port are fairly arbitrary and can be changed</span><span style="box-sizing: border-box; color: #95a5a6;"> * as needed. &nbsp;Just redefine them below.</span><span style="box-sizing: border-box; color: #95a5a6;"> */</span><span style="box-sizing: border-box; color: #5e6d03;">#include</span><span style="box-sizing: border-box; color: #434f54;">&lt;</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">SoftwareSerial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #000000;">h</span><span style="box-sizing: border-box; color: #434f54;">&gt;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_RX_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">10</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">//Soft Serial Receive pin</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_TX_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">11</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">//Soft Serial Transmit pin</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">3</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">//RS485 Direction control</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">13</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">RS485_TRANSMIT</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #00979c;">HIGH</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">const</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #00979c;">LOW</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #434f54;">// Create Soft Serial Port object and define pins to use</span><span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">SoftwareSerial</span></span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_RX_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_TX_PIN</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">byteReceived</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #00979c;">int</span><span style="box-sizing: border-box; color: #000000;">byteSent</span><span style="box-sizing: border-box; color: #000000;">;</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #434f54;">// &nbsp;Initialization</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #00979c;">void</span><span style="box-sizing: border-box; color: #5e6d03;">setup</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">begin</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">9600</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Start the built-in hardware serial port</span>
 &nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">println</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #005c5f;">"Slave Device"</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">pinMode</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">OUTPUT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Configure any output pins</span>
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">pinMode</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">OUTPUT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 in receive mode</span>
 &nbsp;
 &nbsp;<span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">begin</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">9600</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Start the RS485 soft serial port </span><span style="box-sizing: border-box; color: #000000;">}</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #434f54;">// &nbsp;Main</span><span style="box-sizing: border-box; color: #434f54;">//===============================================================================</span><span style="box-sizing: border-box; color: #00979c;">void</span><span style="box-sizing: border-box; color: #5e6d03;">loop</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;<span style="box-sizing: border-box; color: #434f54;">// Watch for data coming in on the soft serial port. &nbsp;If found, send a copy to the </span>
 &nbsp;<span style="box-sizing: border-box; color: #434f54;">// hardware port to display on the local serial terminal and also echo a copy back out </span>
 &nbsp;<span style="box-sizing: border-box; color: #434f54;">// the soft serial port to the Master device &nbsp;</span>
 &nbsp;<span style="box-sizing: border-box; color: #5e6d03;">if</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">available</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">)</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// If data has come in from Master</span>
 &nbsp;<span style="box-sizing: border-box; color: #000000;">{</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">byteSent</span><span style="box-sizing: border-box; color: #434f54;">=</span><span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">read</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Read the byte </span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; font-weight: bolder;"><span style="box-sizing: border-box; color: #d35400;">Serial</span></span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">write</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">byteSent</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Show on local Serial Monitor window</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">HIGH</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Show activity on LED</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">delay</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">10</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_TRANSMIT</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 in Transmit mode &nbsp;&nbsp;&nbsp;</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #000000;">RS485Serial</span><span style="box-sizing: border-box; color: #434f54;">.</span><span style="box-sizing: border-box; color: #d35400;">write</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">byteSent</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Send the byte back to Master</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">delay</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">1</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Wait before going back to Receive mode</span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">SSERIAL_CTRL_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #000000;">RS485_RECEIVE</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Put RS485 back into Receive mode </span>
 &nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #d35400;">digitalWrite</span><span style="box-sizing: border-box; color: #000000;">(</span><span style="box-sizing: border-box; color: #000000;">LED_PIN</span><span style="box-sizing: border-box; color: #434f54;">,</span><span style="box-sizing: border-box; color: #00979c;">LOW</span><span style="box-sizing: border-box; color: #000000;">)</span><span style="box-sizing: border-box; color: #000000;">;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="box-sizing: border-box; color: #434f54;">// Turn LED back off</span>
 &nbsp;<span style="box-sizing: border-box; color: #000000;">}</span> &nbsp;
<span style="box-sizing: border-box; color: #000000;">}</span></pre>
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">BEFORE THEY ARE SHIPPED, THESE MODULES ARE:</h2>
      <ul style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;">Sample inspected and tested per incoming shipment</li>
         </ul>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><em style="box-sizing: border-box;">Notes:&nbsp;</em></p>
      <ol style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px;">
         <li style="box-sizing: border-box;"><i style="box-sizing: border-box;">Note that due to the length of the module, if using with a breadboard,&nbsp; you will need to span two sections of the breadboard.</i></li>
         <li style="box-sizing: border-box;"><em style="box-sizing: border-box;">For a simpler to use and more capable solution with auto direction control, check out the SCM TTL to RS-485 Interface Module below</em></li>
         </ol>
      <hr style="box-sizing: content-box; height: 0px; margin-top: 20px; margin-bottom: 20px; border-right: 0px; border-bottom: 0px; border-left: 0px; border-image: initial; border-top-style: solid; border-top-color: #eeeeee; overflow: visible;" />
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">TECHNICAL SPECIFICATIONS</h2>
      <table class="table table-hover" width="862" style="border-spacing: 0px; background-color: transparent; width: 815px; max-width: 100%; margin-bottom: 20px; height: 140px;">
         <tbody style="box-sizing: border-box;">
            <tr style="box-sizing: border-box;">
               <td width="145" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"><span style="box-sizing: border-box; font-weight: bolder;">&nbsp;Operating Ratings</span></td>
               <td width="264" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"></td>
               <td width="229" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"></td>
               </tr>
            <tr style="box-sizing: border-box;">
               <td width="145" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; V<span style="box-sizing: border-box; font-size: 10.5px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">cc</span></td>
               <td width="264" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">Range</td>
               <td width="229" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">4.75 to 5.25V</td>
               </tr>
            <tr style="box-sizing: border-box;">
               <td width="145" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I<span style="box-sizing: border-box; font-size: 10.5px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">max</span></td>
               <td width="264" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"></td>
               <td width="229" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">5mA (typical measured)</td>
               </tr>
            <tr style="box-sizing: border-box;">
               <td width="145" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"><span style="box-sizing: border-box; font-weight: bolder;">Dimensions</span></td>
               <td width="264" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">L x W (PCB)</td>
               <td width="229" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;">45 x 15mm (1.8 x 0.6″)</td>
               </tr>
            <tr style="box-sizing: border-box;">
               <td width="145" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"><span style="box-sizing: border-box; font-weight: bolder;">Datasheets</span></td>
               <td width="264" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"></td>
               <td width="229" style="box-sizing: border-box; padding: 8px; line-height: 1.42857; vertical-align: top; border-top-style: solid; border-top-color: #dddddd;"><span style="box-sizing: border-box; color: #0000ff;"><span style="box-sizing: border-box; font-weight: bolder;"><a href="https://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf" target="_blank" rel="noopener noreferrer" style="box-sizing: border-box; background-color: transparent; color: #0000ff; text-decoration-line: none;">MAX485</a></span></span></td>
               </tr>
            </tbody>
         </table>
      <hr style="box-sizing: content-box; height: 0px; margin-top: 20px; margin-bottom: 20px; border-right: 0px; border-bottom: 0px; border-left: 0px; border-image: initial; border-top-style: solid; border-top-color: #eeeeee; overflow: visible;" />
      <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">FURTHER READING</h2>
      <p style="box-sizing: border-box; margin-bottom: 20px;"><a href="http://www.gammon.com.au/forum/?id=11428" target="_blank" rel="noopener noreferrer" style="box-sizing: border-box; background-color: transparent; color: #000000; text-decoration-line: none;">Nick Gammon has an excellent write-up on the RS485 standard and has implemented several useful libraries.</a></p>
      </div>
   </div>
<section class="up-sells upsells products" style="box-sizing: border-box; font-family: &quot;Open Sans&quot;, Helvetica, Arial, sans-serif; font-size: 14px; background-color: #f5f5f5;">
   <h2 style="box-sizing: border-box; font-family: Montserrat, Helvetica, Arial, sans-serif; line-height: 20px; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 18px; text-transform: uppercase;">YOU MAY ALSO LIKE…</h2>
   <ul class="products columns-4" style="box-sizing: border-box; margin: 0px -15px; clear: both; padding: 0px; list-style: outside none;">
      <li class="prodpage-classic product type-product post-6984 status-publish first instock product_cat-communications-and-interfacing product_cat-ic-breakout-modules product_tag-rs-485 has-post-thumbnail taxable shipping-taxable purchasable product-type-simple" style="box-sizing: border-box; list-style: outside none; float: left; margin: 0px 0px 30px; padding: 0px 15px; position: relative; width: 292.484px; clear: both;">
         <div class="product-list-item text-custom-parent-hov prod-layout-classic" style="box-sizing: border-box; position: relative; background: radial-gradient(at center center, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 50%, rgb(237, 237, 237) 100%);"><a href="https://protosupplies.com/product/scm-ttl-to-rs-485-interface-module/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" style="box-sizing: border-box; background-color: transparent; color: #000000; text-decoration-line: none; display: block; position: relative;" target="_blank">
               <div class="zn_badge_container" style="box-sizing: border-box; position: absolute; top: 20px; left: 20px; z-index: 1;">&nbsp;</div>
               <span class="kw-prodimage" style="box-sizing: border-box; text-align: center; overflow: hidden; position: relative; z-index: 0; display: block;"><img src="https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1-400x300.jpg" class="kw-prodimage-img" alt="SCM TTL to RS-485 Adapter Module" loading="lazy" srcset="https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1-400x300.jpg 400w, https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1-300x225.jpg 300w, https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1-768x576.jpg 768w, https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1-249x187.jpg 249w, https://protosupplies.com/wp-content/uploads/2019/02/SCM-TTL-to-RS-485-Adapter-Module-1.jpg 800w" sizes="(max-width: 400px)