I'm trying to achieve RS485 communication between Arduino Mega and Arduino UNO as specified in following link:
But now my problem is The master i.e. Arduino Mega doesn't print anything on Serial Monitor.
Please help me out to solve this issue, trying from week still no success.
Sir Peter Paul Kiefer,
Im attaching my circuit setup
Master Code/Mega code
void setup()
{
//Using Serial1 Port
Serial1.begin(9600);
Serial.begin(9600);
//DE/RE Controling pin of RS-485
pinMode(8, OUTPUT);
}
void loop()
{
char getdata='m';
//DE/RE=HIGH Transmit Enabled M1
digitalWrite(8,HIGH);
//Write '9' and Fetch Data From Pro Mini
Serial1.print('9');
//DE/RE=LOW Receive Enabled M1
digitalWrite(8,LOW);
delay(1000);
//If Serial Data is available
if(Serial1.available())
{
while( Serial1.available() && getdata!='d' )
{
getdata=Serial1.read();
Serial.print(getdata);
}
Serial.println("");
}
}
Slave code
void setup()
{
//Serial1.begin(9600);//Uncomment for Arduino Lenardo
Serial.begin(9600);
//while(!Serial1);//Uncomment for Arduino Lenardo
//Led Connected
pinMode(13, OUTPUT);
//DE/RE Controling pin of RS-485
pinMode(8, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
char getdata='c';
//Led OFF
digitalWrite(13,LOW);
//DE/RE=LOW Receive Enabled
digitalWrite(8,LOW);
if(Serial.available())
{
getdata=Serial.read();
}
if(getdata=='9')
{
//DE/RE=HIGH Transmit Enabled
digitalWrite(8,HIGH);
Serial.print("AcruxTek");
Serial.print("Isld");
}
delay(2000);
//Led ON
digitalWrite(13,HIGH);
delay(2000);
}
I connected gnd of RS485 converter to arduino gnd and also i did common gnd between circuits but still no output. I used same code nothing changed.. except one thing the example uses arduino pro mini but i used arduino uno as slave
