After getting sick of worrying about flow control and fried MAX485 chips I shelled out the money to purchase a few industrial converters.
I picked them up, loaded some simple scripts onto my mega and dumilanove then set about testing them. Despite hooking them up as per instructions they wouldn't work. It didn't matter what I tried.
Does anybody have any idea what I'm doing wrong?
//for the sender
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("d");
delay(50); // send over the letter d forever
}
////////////////////////////////////////////////////////////////////////////
//for the receiver, receives a character then spits it out to the serial monitor
char receivedChar;
boolean newData = false;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial2.begin(9600);
delay(20);
}
void loop() {
// put your main code here, to run repeatedly:
//listen and push everything to serial monitor
if (Serial2.available() > 0) {
receivedChar = Serial2.read();
newData = true;
}
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChar);
newData = false;
}
}
I'm worried about damage to my arduino since the environment I work in tends to have lots of static. Could that be causing any issues? I don't think it is since I can communicate over TTL just fine.