Hi All,
I'm using a max481E RS485 chip with a few Arduinos connected. This chip needs two pins changed to allow sending or receiving. The problem is that I have made a function that will set the pin then send the data and then change the pin back. Only one character is sent and the pin is set back to LOW. I think this is because the serial.write is shifting data into a buffer and then the hardware for the serial takes over and sends it.
Is there a way to know when the data is sent or wait until the data is sent and then change the pin state.
void commWrite(char * data,int dataSize){
digitalWrite(commsTX,HIGH);
for(int i = 0; i < dataSize;i++){
Serial.write(data[i]);
}
digitalWrite(commsTX,LOW);
}
Thanks