Lantronix Analog Sender

Here’s a short Wiring/Arduino program that waits for a connection to the microcontroller via a Lantronix device, and sends out an analog reading when it’s got a connection.

The Lantronix device is in connectMode D4, and the TX is connected to the Arduino’s RX and vice versa.

 Ethernet Data reporter
 for use with a Lantronix Xport, Xport Direct, or other
 device in the same family.

 If a remote device connects via the Xport
 (in connectMode D4), the microcontroller waits for bytes.
 If it gets a D or N, it thinks it's disconnected.
 Any other byte, and it thinks it's connected.
 When connected, it sends out analog readings.

 created 9 Sep 2008
 by Tom Igoe


#define CONNECTED 1

int inByte;    // for incoming bytes
int status;    // whether or not you're connected

void setup() {

void loop() {
  // read new characters into a string:
  if (Serial.available()) {
    inByte =;
    // if you get a D or N, disconnect.
    // otherwise, you're connected:
    if (inByte == 'D' || inByte == 'N') {
      status = DISCONNECTED;
    else {
      status = CONNECTED;

  // if connected, send out the analog value:
  if (status == CONNECTED) {
    Serial.print("Analog reading: ");
    Serial.println(analogRead(0), DEC);