Arduino + DX160 Serial LCD

Has anyone tried interfacing an Arduino NG board with a DX-160 Serial LCD from SF? The screen comes on and shows the startup screen, but I can’t seem to get any command to work except the clear screen command (186).

I’ve done programming on a PC before, but I’m a complete newbie when it comes to microcontrollers, etc. I have done some simple stuff with the Arduino and LED’s and serial communication to the PC, but this was going to be the next “step” in learning about this kind of thing.

I’m sure there is something extremely simple that I’m missing. I’ve spent some time on Google looking up information on this particular combination, but as far as I can tell I’m the first. And I’ve looked at other code for other serial screens, but I still can’t tell what I’m doing wrong.

Here’s some sample code (I’ve got the board powered by USB, an LED connected to pin 13, and the tx pin on the board connected to TTL on the screen. By the way, I can see the commands in the IDE with the serial monitor on. I had thought that the board was sending commands over USB and not out tx, so I powered it using a wall wart, but this did not fix anything.):

int ledPin = 13;   // select the pin for the LED

void setup() {
  pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
  Serial.begin(57600);      // connect to the serial port
}

void loop () {

  Serial.print(185,BYTE);
  Serial.print(186,BYTE);
  Serial.print(180,BYTE);
  Serial.print("Hello, world!");
  Serial.print(255,BYTE);
  Serial.print(181,BYTE);
  Serial.print("Hello, world!");
  Serial.print(255,BYTE);
  digitalWrite(ledPin, LOW);
  delay(10000);
  Serial.print(185,BYTE);
  digitalWrite(ledPin, HIGH);
  delay(10000);
}

If you do not wait between commands the dx160 will just ignore the command. The wait times vary from my experience and they are not documented in the least.

On the safe side I wait one millisecond after every byte sent and then after a large operation like clearing the screen or a graphics operation I wait 5-10ms more.

Hope that helps,

Rick

Hey Guys,

I am trying to figure out the DX160 + Arduino. and stock at the same place where I can only get the clean screen ASCII[186] to work… Anyone has any further information on this?

Thanks

Ghetto

rfryar is correct, the wait time inbetween sending commands is different. You’ll have to mess around with different values. I am using the DX160 with a PIC and, after messing around a bit, was successfully able to get it to work. I’m still trying to figure out a few “quirky” bugs, but for the most part it works fine now. I don’t know anything about Arduino however.

If anything, try calling the manufacturer (one guy). His name is Rene Teo and was extremely helpful with me. His email is rmteo@earthlink.net . I can’t seem to find his phone number anywhere, but email him with your number and he’ll contact you via phone.

I’m having precisely the same problem. Does anyone have any examples of code that works? I’ve e-mailed the guy mentioned in the previous post…

I’m using an Arduino Diecimila.

I’ve since talked to Rene, he’s a nice guy, very willing th help.

Basically what I’ve done:

I’ve run the “test” program and controlled the display. I’ve done this by hooking the display up to my Arduino’s RX pin and sending data to Arduino… so the board will see that data.

That works very well and properly. I realized it may not be the correct way to do it, but it works.

Using the Arduino:

I’ve managed to change the baud rate to 9600, that fixed nothing for me. I’ve since reset it back to 57600.

I can occasionally get commands to go through. Clear Screen is the only one that’s ever gone through 100% correct. It occasionally outputs garbage on the screen with other data sent.

I’ve tried both the TTL and RS232 pins. No real significant difference at this point with either. TTL is said to be the one to use, so I’m currently sticking with that.

I guess the question at this point is: Is it inverted or non-inverted signal? How does one change/fix/alter that?

When I finally figure this out and get it to work, I will post example code on how it works with Arduino. I know it can, and will work, I just have no idea how to get it to work.

If you have any info/suggestions on how to solve this, I’d really like to hear them, otherwise I’ll just keep plugging away at it.

I found out what my problem was…

I failed to put in the end-of-string command, I also wasn’t outputting my commands to the screen as BYTE, and also the delay is very important. I see the example code above has just about everything, except the delay. I had the delay and failed to realize that I was missing the other stuff. Here’s some example code, that works with an Arduino Diecimila:

/*
 * Hello World!
 *
 * This is the Hello World! for Arduino. 
 * outputs to DX160.
 */


void setup()                    // run once, when the sketch starts
{
  Serial.begin(57600);           // set up Serial library at 57600 bps
  Serial.print(186,BYTE);        // Clears the screen (DX160)
  delay(1000);                   // waits a second
  Serial.print("Hello world!");  // prints Hello world! 
  delay(10);                     // waits...
  Serial.print(255,BYTE);        // sends the end-of-string command - gives the "OK" for the DX160 to print.
}

void loop() {
  
}

I cannot seem to get lines and shapes to draw. Also, I cannot get the “hello world” application to work properly. Its very odd, I have to put the Serial.print(“hello world!”) function in the loop function. Then, i have to unplug the device, and repower it when the loop function is working. Here is the code i have for drawing a line. Does anyone have any ideas?

void drawLine(int x1,int y1,int x2,int y2)

{

Serial.print(200,BYTE);

delay(50);

Serial.print(4,BYTE);

delay(50);

Serial.print(x1,BYTE);

delay(50);

Serial.print(y1,BYTE);

delay(50);

Serial.print(x2,BYTE);

delay(50);

Serial.print(y2,BYTE);

delay(50);

Serial.print(200,BYTE);

delay(50);

}

void setup() // run once, when the sketch starts

{

Serial.begin(57600); // set up Serial library at 57600 bps

Serial.print(186,BYTE); // Clears the screen (DX160)

delay(1000); // waits a second

Serial.print(“Hello world!”); // prints Hello world!

delay(10); // waits…

Serial.print(255,BYTE); // sends the end-of-string command - gives the “OK” for the DX160 to print.

}

void loop()

{

delay(3000);

drawLine(10,10,80,10);

}

dimitris, you aren’t sending the required “color” parameter for the line-drawing command.

has anybody gotten bitmaps to work via arduino? I’ve been trying for a while with no luck. sometimes my code corrupts the arduino bootloader, other times nothing happens, other times I get garbage on the screen…but never a bitmap.

one odd thing I’ve found is that if I put the bitmap code into a function, it can crash the arduino or cause other problems even if I don’t call the function.

here is my current code:

http://divinepenguin.com/processing/ard … Bitmap.txt

text, graphics, etc are working fine for me.