OLED display crashes when connecting USB I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode, but just if the USB isn't connected and it is powered by a 9V power supply.

So my routine is:


Connect USB and power supply
Upload Code
--> Doesn't work
Disconnect USB and power supply
Just connect power supply
--> Works
Connect USB
--> Display crashes


So basically: If the arduino is connected via USB to my PC, with or without an additional power supply, the display won't work properly, it will crash or the Arduino even restarts itself. (some kind of memory error?) 

I have no possible explanation for this..

Thanks for your help.

EDIT: I'm running Ubuntu Mate Kernel 4.4.0-43-generic 64bit

If I plug in the cabel without power, display works fine.
If I plug in the cabel with 5V, but the PC is shut down, the display works fine.
For the display to crash, the pc has to be running.

Test code:

#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
    //lcd.clear();
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Hello there");
    delay(1000);
}

void loop()
{
    lcd.setCursor(0,1);
    lcd.print("Hello World");

    lcd.setCursor(0,0);
    lcd.print("ABCDEFGHIJKLM");

    delay(1800);

    lcd.clear();

}
When your computer boots, or when you plug the board in with it booted, most likely the serial port that gets created (/dev/ttyACM0) is opened by the process modem-manager. That will cause the Arduino to reset giving you the same results you see when you reset the board in other ways.

I have had no end of trouble in the same manner with a green version of the same screen. The best results I have had is to control the power to the display and power it up at every boot.  You can do it with a simple P-channel logic level MOSFET or PNP transistor:







simulate this circuit &ndash; Schematic created using CircuitLab

If you chose, say, D3 (as an example) as your control GPIO you would go:

void setup() {
    pinMode(3, OUTPUT);
    digitalWrite(3, LOW);
    delay(1000); // Give it time to settle after powering up
    ... rest of setup code ...
}


You can also then use it to save power (if you want to) by turning the display off - simply set the pin back to INPUT and it will be turned off by R1.