I'm not even trying to turn the line at this point... strictly one-way communication not happening.
Here is some code from the Yourduino site I adjusted for the Slave. Note the constantly-'LOW' RE/DE pin, i.e. receive mode only.
/* YourDuino RS485 Slave Node A Example
terry@yourduino.com */
/*-----( Declare Variables )-----*/
int ledPin=13;
int EN = 6;
byte Val;
void setup()/****** SETUP: RUNS ONCE ******/
{
pinMode(ledPin, OUTPUT );
pinMode(EN, OUTPUT );
Serial.begin (28800);
Serial.println("Setup Complete.");
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
// receive Data
digitalWrite (EN, LOW ); // enable receive
Val = Serial.read ();
Serial.println(Val);
if (-1 != Val)
{
if ( 'A' == Val)
{
digitalWrite (ledPin, HIGH );
delay (500);
digitalWrite (ledPin, LOW );
delay (500);
}
}
}//--(end main loop )---
And here is the master code. It is running on a 1284P, the first serial bus ends in the FTDI header, while Serial1 is attached directly to the RS485 chip inputs. I probably should simplify this to the point where the RE/DE pin is always high and see if that makes any difference.
/* YourDuino RS485 Master Node Example
terry@yourduino.com */
/*-----( Declare Variables )-----*/
int EN = 12;
int LED_PIN =7;
void setup() /****** SETUP: RUNS ONCE ******/
{
pinMode(EN, OUTPUT );
pinMode(LED_PIN, OUTPUT );
Serial.begin (28800);
Serial1.begin (28800);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
// Send Data
digitalWrite(LED_PIN, HIGH ); // turn on light
Serial.print ( 'A' ); //FTDI Header Send
digitalWrite(EN, HIGH ); // enable send
delay (1); //wait for RS485 chip to be active
Serial1.print ( 'A' ); //RS485 Bus Send
delayMicroseconds (660); ////delay recommended by Nick Gammon to deal with the serial buffer clearing before TX is complete
digitalWrite(EN, LOW ); // disable send
delay(1000);
digitalWrite(LED_PIN, LOW ); // turn off light
Serial.print ( 'B' );//FTDI Header Send
digitalWrite(EN, HIGH ); // enable send
delay(1); //wait for RS485 chip to be active
Serial1.print ( 'B' ); //RS485 Bus Send
delayMicroseconds (660); //delay recommended by Nick Gammon to deal with the serial buffer clearing before TX is complete
digitalWrite(EN, LOW ); // disable send
delay (1000);
}//--(end main loop )---