writing to an OLED display

I'm trying to display messages on an OLED display that I've been using with a Picaxe computer. With the Picaxe the interface to the display is 2400 baud, 8 data bits, no parity, one stop bit.

The display works fine with the Picaxe, but when I try using it on a Arduino UNO it displays garbage.

below is the very simple sketch I'm trying to make work.

(I'm very new to Arduino.)

void setup() { Serial.begin(2400); delay(1000); }

void loop() { Serial.println("Hello World"); delay(2000); }

Hi, welcome to the forum.

Can you tell which display it is ? you can copy a link in the post. How did you connect it ?

It’s a Picaxe AXE133 Serial OLED display.

The wiring is +5, GND, and data.

I hooked the data line to pin 1 (TX) on the Adruino board.
+5 and GND also from the Adruino board.

The display powers up and goes through it’s initilization.
But, when the Adruino does the Serial.print(“Hello World”), garbage shows on the display screen.

The display requires 2400 baud, 8 bits data, no parity, one stop bit.

This module : http://www.picaxe.com/Hardware/Add-on-Modules/Budget-Serial-OLED-Module/

When you set the Arduino to "Serial.begin(2400)", it is 2400,N,8,1. That is correct. You wait at least 500ms before sending a message, that is also correct.

Did you connect the display 'data' pin to Arduino pin 1 ?

I think you have to send the command to move to the first line, command : 254,128

void setup() 
{  
  Serial.begin(2400);
  delay(1000);              // wait at least 500ms for display after power on
}

void loop()
{
  Serial.write(254);      // command 254, 128
  Serial.write(128);
  Serial.print("Hello World");
  delay(2000);
}

I think the Serial.write will send a character above 127 as normal binary data.

Yes- the data line is hooked to pin 1 on the Arduino.

Your correct about the command bytes to position the cursor. When I was not able to make it work correctly I took all of that out to simplify the code.

I've not had any trouble using the display on Picaxe projects. I found the following in the Picaxe manual.

Might this have something to do with the trouble I'm having?

(from Picaxe manual)

"Baud mode specifies the baud rate and polarity of the signal. When using a simple resistor interface, use N (inverted) signals. When using a MAX232 type interface use T (true) signals. The protocol is fixed at N,8,1 (no parity, 8 data bits, 1 stop bit).

A ‘N’ baud rate idles low, with data pulse going high. A ‘T’ baud rate idles high, with data pulses going low. When using a T baud rate the very first byte may become corrupt if the output pin was low before the serout command (the pin will be automatically left high after the serout command). To avoid this issue place the line high (via a’high’ command’) a few milliseconds before the very first serout command."

You probably read my current signature : "Don't laugh at me but I thought for years that RX and TX were low when they are not active. They are not, they are high when not active... Okay, go ahead, laugh yourself silly".

I know now (since a few days) that the Arduino is idle high, and the data pulses going low. The display wants it the other way around ?

Let's try something different: SoftwareSerial. The SoftwareSerial library is a software implementation of a serial port. It can be used on any pin of the Arduino Uno. And the cool thing is that the signal can be inverted.

Use a part from this example: http://arduino.cc/en/Reference/SoftwareSerial Suppose RX is at 10 and TX is at 11, add the undocumented third parameter to inverse the signal. Connect Arduino pin 11 to your display.

SoftwareSerial mySerial(10, 11, true); // RX, TX, inverted

This is the source code of Software Serial that is capable to invert the signal : https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp