Crossroads,
Thanks for the quick reply. Quite angry at myself that with these strong storms kicking up around here, I left work in a rush without my boards to work on tonight.
For your first question, I would much rather send only one byte if only one has changed. I just didn't know how to decipher on the receiving end, which port the incoming byte was meant for (PORTA, PORTC, or PORTL).
I see what you mean about the flag's now for sending but just want to clarify something, when you said "do that for all 3", do I need to use a different variable (byteA, byteC, byteL) for each byte to send? I noticed on your 2nd code block, you wrote:
RS485Serial.write(byteA); // Send the byte back
RS485Serial.write(byteA); // Send the byte back
RS485Serial.write(byteA); // Send the byte back
I'm guessing it should be the 3 different variables?
So on the receiving end, if the sent bytes could be for all or any one of the 3 ports, how would I go about telling the master which one of the 3 ports was the incoming byte intended for?
As for using Software Serial, this is my first shot at serial communications and I have done a lot of research and found a few options and this is one that I was able to get to work and figured its what I needed to use. Now that I'm getting a little better grip on this and have some basic understandings, do you think I should just use the TX-RX pins instead? It DOES seem like there might be a lot of un-wanted overhead whenever a library is used. I'll try the standard TX-RX pins in the morning, I also used the Software Serial library for the receiving master sketch as well.
I appreciate your help in figuring this out...Thx
Here is the simple Master Sketch, I'll get rid of SSerial tomorrow on this one also:
#include <SoftwareSerial.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define SSerialRX2 10 //Serial Receive pin
#define SSerialTX2 11 //Serial Transmit pin
#define SSerialTxControl 3 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
#define Pin13LED 13
SoftwareSerial RS485Serial(SSerialRX2, SSerialTX2); // RX, TX
/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;
byte incomingByte;
void setup() /****** SETUP******/
{
pinMode(Pin13LED, OUTPUT);
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Receive); // Init Transceiver
RS485Serial.begin(9600); // set the data rate
//===============================SETUP@=======================================================
//===PORTA
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
pinMode(28, OUTPUT);
pinMode(29, OUTPUT);
//===PORTC
pinMode(30, OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
pinMode(33, OUTPUT);
pinMode(34, OUTPUT);
pinMode(35, OUTPUT);
pinMode(36, OUTPUT);
pinMode(37, OUTPUT);
//===PORTL
pinMode(42, OUTPUT);
pinMode(43, OUTPUT);
pinMode(44, OUTPUT);
pinMode(45, OUTPUT);
pinMode(46, OUTPUT);
pinMode(47, OUTPUT);
pinMode(48, OUTPUT);
pinMode(49, OUTPUT);
}//--(end setup )---
//-----------------------------------------------------------------------------------------------------------------------------
void loop()
{
if (RS485Serial.available()) //Look for data from other Arduino
{
incomingByte = RS485Serial.read();
PORTA = incomingByte; // D22 - D29
/*--------------------Need to figure out how to delegate these ports from incoming bytes
PORTC = incomingByte; // D30 to D37
PORTL = incomingByte; // D42 to D49
*/
}
}//--(end main loop )---