by erikroby » Mon Jun 04, 2012 2:39 pm
I just bought one of the 16x2 blue OLEDs, and I am having some trouble getting it to work. I connected it just like I would a normal 16x2 LCD (the pins I am using seem to be the same according to the spec sheets, except for the LED and contrast pins which are not there). I am using the same sketch to test it:
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("designed by");
lcd.setCursor(0,1);
lcd.print("Erik Roby");
delay(3000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("void loop");
delay(3000);
lcd.clear();
delay(1000);
}
The display lights up, although the "designed by" and "Erik Roby" are displayed on the wrong lines, "designed by" shows up on the bottom row instead of the top. (When I say "wrong" this is compared to what I was expecting because of how it would show up on my 16x2 LCD.)
After the setup it will display "void loop", also on the bottom row. Then it clears once or twice and on the second, third, or fourth time running through the loop it will only show "v" and then freeze there. It seems a little odd to me that the loop will run a few times and then stop, and also that on the last time it only shows the first letter of the loop. The number of times it will run the loop varies, but has always been between 2 and 4 times. Are there different commands for the OLED vs LCD? Do I need to use different data pins than I would with the LCD?
If anyone else has run into this issue with a direct swap of the displays please let me know! I will try it with different cables and a different arduino tonight.
Thanks!
-Erik