Advertisement
pleasedontcode

RS485 Receiver

Aug 1st, 2024
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.39 KB | Source Code | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial RS485Serial(2, 3); // RX, TX
  4.  
  5. void setup() {
  6.   pinMode(4, OUTPUT); // Control the DE/RE pin
  7.   digitalWrite(4, LOW); // Set to receive mode
  8.   RS485Serial.begin(9600);
  9.   Serial.begin(9600);
  10. }
  11.  
  12. void loop() {
  13.   if (RS485Serial.available()) {
  14.     String message = RS485Serial.readString();
  15.     Serial.println("Received: " + message);
  16.   }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement