nick gammon rs485 blocking

i am using rs485 with multiple arduinos (1 master, 2 slaves). The code is working with a single master and slave setup but when i connect the second slave, the second slave hears nothing.. plxx guide me! The code is mentioned below. For the second arduino i used a second msg..

//Master sketch

#include "RS485_protocol.h"
#include <SoftwareSerial.h>

const byte ENABLE_PIN = 3;
const byte LED_PIN = 13;

SoftwareSerial rs485 (10, 11); // receive pin, transmit pin

// callback routines

void fWrite (const byte what)
{
rs485.write (what);
}

int fAvailable ()
{
return rs485.available ();
}

int fRead ()
{
return rs485.read ();
}

void setup()
{
Serial.begin(9600);
rs485.begin (9600);
pinMode (ENABLE_PIN, OUTPUT); // driver output enable
pinMode (LED_PIN, OUTPUT); // built-in LED
} // end of setup

byte old_level = 0;

void loop()
{

// read potentiometer
byte level = analogRead (0) / 4;
Serial.println(level);
delay(100);

// no change? forget it
if (level == old_level)
return;

// assemble message
byte msg [] = {
1, // device 1
2, // turn light on
level // to what level
};

byte msg1 [] = {
5, // device 2
2, // turn light on
level // to what level
};

// send to slave
digitalWrite (ENABLE_PIN, HIGH); // enable sending
sendMsg (fWrite, msg, sizeof msg);
digitalWrite (ENABLE_PIN, LOW); // disable sending
delay(1000);
digitalWrite (ENABLE_PIN, HIGH); // enable sending
sendMsg (fWrite, msg1, sizeof msg1);
digitalWrite (ENABLE_PIN, LOW); // disable sending
// Serial.print(fWrite);

// receive response
byte buf [10];
byte received = recvMsg (fAvailable, fRead, buf, sizeof buf);
// Serial.print(received);
digitalWrite (LED_PIN, received == 0); // turn on LED if error

// only send once per successful change
if (received)
old_level = level;
delay(2000);

//Slave sketch 1

#include <SoftwareSerial.h>
#include "RS485_protocol.h"

SoftwareSerial rs485 (7, 5); // receive pin, transmit pin
const byte ENABLE_PIN = 4;

void fWrite (const byte what)
{
rs485.write (what);
}

int fAvailable ()
{
return rs485.available ();
}

int fRead ()
{
return rs485.read ();
}

void setup()
{
Serial.begin(9600);
rs485.begin (9600);
pinMode (ENABLE_PIN, OUTPUT); // driver output enable
}

void loop()
{
byte buf [10];

byte received = recvMsg (fAvailable, fRead, buf, sizeof (buf));

if (received)
{
if (buf [0] != 2)
return; // not my device

if (buf [1] != 2)
return; // unknown command

byte msg [] = {
0, // device 0 (master)
3, // turn light on command received
};

delay (1); // give the master a moment to prepare to receive
digitalWrite (ENABLE_PIN, HIGH); // enable sending
sendMsg (fWrite, msg, sizeof msg);
delayMicroseconds (660);
digitalWrite (ENABLE_PIN, LOW); // disable sending

analogWrite (3, buf [2]); // set light level
} // end if something received

}

//Slave sketch 2

#include <SoftwareSerial.h>
#include "RS485_protocol.h"

SoftwareSerial rs485 (52, 53); // receive pin, transmit pin
const byte ENABLE_PIN = 4;

void fWrite (const byte what)
{
rs485.write (what);
}

int fAvailable ()
{
return rs485.available ();
}

int fRead ()
{
return rs485.read ();
}

void setup()
{
Serial.begin(9600);
rs485.begin (9600);
pinMode (ENABLE_PIN, OUTPUT); // driver output enable
}

void loop()
{
byte buf [10];

byte received = recvMsg (fAvailable, fRead, buf, sizeof (buf));

if (received)
{
if (buf [0] != 5)
return; // not my device

if (buf [1] != 2)
return; // unknown command

byte msg [] = {
0, // device 0 (master)
3, // turn light on command received
};

delay (1); // give the master a moment to prepare to receive
digitalWrite (ENABLE_PIN, HIGH); // enable sending
sendMsg (fWrite, msg, sizeof msg);
delayMicroseconds (660);
digitalWrite (ENABLE_PIN, LOW); // disable sending

analogWrite (51, buf [2]); // set light level
} // end if something received

} // end of loop

Please go back and edit your code to use code tags.

Next, you connect something, then the problem begins and we get no schematic?

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long to study quickly without copying to a text editor.

What has Nick Gammon got to do with your problem?

...R