Serial loopback, TX to RX not working


hi all.  have project i'm working on , running wall getting serial communication working, reading fine, writing didn't seem work.  unfortunately device didn't have led monitor if receiving, transmitting.  running through level converter, , suspected had issue there.

so wrote sketch below write serial port on mega 2560, read port see if getting same data back;  wasn't.  took level converter out, , jumpered tx rx serial 3, , still had problems.

the sketch generates random character, a-z, sends out both serial console , serial3, waits input on same port, reads it, , prints on serial console. i'm never getting same character sent.  hardware standpoint, don't see why shouldn't work, , i'm not spotting obvious software.  know might doing wrong here?


code: [select]
void setup()
{
  serial.begin(9600);
  serial.println("starting");

  // set data rate softwareserial port
  serial3.begin(9600);
  int c = random(65,90);
  serial3.write(c);
  serial.write(c);

}

void loop() // run on , over
{
  if (serial3.available())
  {
      serial.println(serial3.read());
      int c = random(33,55);
      serial3.write(c);
      serial.write(c);
  }
 
  delay(100);
}

serial reads & writes bytes, not ints.
try changing c int byte.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Serial loopback, TX to RX not working


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial