Hello,
Im attempting to get two arduinos to communicate via RS485, I have a nano as the master and an uno as the slave. Im following a video that walks through it but its not working for me, ive tried several videos now. On the Nano im printing to a new line the letter A, when the letter A is seen by the Uno it should turn off an LED for 1 second. Some trouble shooting steps ive taken are making sure that every pin is properly connected and that all wries are in the correct spot. Below is my master code:
#define MASTER_EN 8
void setup() {
Serial.begin(9600);
pinMode(MASTER_EN, OUTPUT);
digitalWrite(MASTER_EN, HIGH);
}
void loop() {
digitalWrite(MASTER_EN, HIGH);
delay(100);
Serial.println('A');
Serial.flush();
digitalWrite(MASTER_EN, LOW);
delay(1000);
}
Here is my slave code:
#define LED 12
#define SLAVE_EN 8
void setup() {
digitalWrite(LED, OUTPUT);
digitalWrite(SLAVE_EN, OUTPUT);
Serial.begin(9600);
digitalWrite(SLAVE_EN, LOW);
}
void loop() {
while(Serial.available()) {
if(Serial.read() == 'A') {
digitalWrite(LED, HIGH);
}
}
}
Here is my wiring diagram, note, I am not using a button, my code is basically a combo of two or more that I found online:
Here are a few pictures of my current setup incase anyone sees anything obvious that I may be missing:
Both:
Slave:
Master:
Is there an easier way to do this? I feel like im missing something. Im building an ROV and have finished everything I want on the ROV but I used I2C for that. I need to figure out how to rewrite the code using RS485 protocol if I want to get to depth. Let me know if have any good tutorials because im not finding much. Thanks again!