Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based RS-485 Communication System with Pushbutton Activation and LED Indicator

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based RS-485 Communication System with Pushbutton Activation and LED Indicator

Circuit Documentation

Summary

The circuit in question is designed to demonstrate a communication system using two RS-485 modules interfaced with two Arduino UNO microcontrollers. The RS-485 standard allows for robust serial communication over long distances and in electrically noisy environments. One Arduino acts as a master, sending a message when a pushbutton is pressed, while the other Arduino acts as a slave, receiving the message and responding by lighting up an LED. The system is powered by two separate 9V batteries.

Component List

Microcontrollers

Communication Modules

Power Sources

Indicators and Interfaces

Passive Components

Comments

Wiring Details

Arduino UNO (Master)

Arduino UNO (Slave)

RS-485 Module (Master)

RS-485 Module (Slave)

LED (Red)

Pushbutton

Resistor (100 Ohms)

Documented Code

Arduino UNO (Master) Code

#define MASTER_EN 8
#define SWITCH 2
void setup() {
  // put your setup code here, to run once:
  pinMode (SWITCH , INPUT_PULLUP) ;
  pinMode (MASTER_EN , OUTPUT) ;
  Serial.begin (9600);
  digitalWrite (MASTER_EN , LOW) ;
}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead (SWITCH) == 0)
  {
    delay (1000);
    digitalWrite (MASTER_EN , HIGH) ;
    delay (5);
    Serial.print ("EMBEDDED GATE*") ;
    Serial.flush ();
    digitalWrite (MASTER_EN , LOW) ;
  }
}

This code configures the master Arduino to send a message "EMBEDDED GATE*" over the RS-485 module when the pushbutton is pressed.

Arduino UNO (Slave) Code

#define SLAVE_EN 7
#define LED 8
String recInput;
void setup() {
  // put your setup code here, to run once:
  pinMode (LED , OUTPUT) ;
  pinMode (SLAVE_EN , OUTPUT) ;
  Serial.begin (9600);
  digitalWrite (SLAVE_EN , LOW) ;
}

void loop() {
  // put your main code here, to run repeatedly:
  while (Serial.available())
  {
    recInput = Serial.readStringUntil('*');
    Serial.print(recInput);
    if (recInput == "EMBEDDED GATE")
    {
      digitalWrite(LED, HIGH);
      delay(1000);
      digitalWrite(LED, LOW);
    }
  }
}

This code configures the slave Arduino to listen for the message "EMBEDDED GATE*" from the master. Upon receiving the message, it turns on the LED for 1 second.

(Note: The code for the 9V Battery microcontroller instances is empty and thus not included in the documentation.)