OLed LCD only shows text after Reboot

Hi Guys,

I just finished my Password Wallet with an OLed display.
The only flaw is, that the display only shows text after rebooting or reprogramming the Arduino Leonardo.

The display is connectet via i2c with 10k pullups and i used the Adafruit Lib.

Can someboy help me ?

Hi,

Sounds like your code is only writing text once to the display after rebooting or reprogramming.

Yours,
TonyWilk

This is a part of my Code. I just tried the example sketch and its also not working propperly.
Do i need this reset pin on I2C? If i need this pin how do i connect it? The LCD only have SDA SCL VCC and GND pins, no RST.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Keyboard.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

const int scrollButton =  1;
const int toggleButton =  0;
byte scrollValue = 1;
byte accesControll = 0;
byte digits;
byte pinCode[4];
byte delayOne;

void setup()
{
  Serial.begin(9600);
  pinMode(scrollButton, INPUT);
  pinMode(toggleButton, INPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
}

falkowa:
This is a part of my Code.

Well, that's a start. Post the whole code.

I have no idea what display you are using. "an OLed display" could be one of many.

Go here: oled breakouts and look at the Wiring... link relevant to the display you have.

Yours,
TonyWilk

Haha sorry ::slight_smile: . Here is the hole code. I bought this 4 pin >OLed< and I use a Beatle as Leonardo.

ps: im not the best programmer in the world ^^

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Keyboard.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

const int scrollButton =  1; 
const int toggleButton =  0; 
byte scrollValue = 1;
byte accesControll = 0;
byte digits; 
byte pinCode[4];

String site1 =  ""; String site2 =  ""; String site3 =  ""; String site4 =  ""; String site5 =  ""; // Loggin Data
String user1 =  ""; String user2 =  ""; String user3 =  ""; String user4 =  ""; String user5 =  "";
String pass1 =  ""; String pass2 =  ""; String pass3 =  ""; String pass4 =  ""; String pass5 =  "";



void setup()
{
  Serial.begin(9600);
  pinMode(scrollButton, INPUT);
  pinMode(toggleButton, INPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop()
{
  byte scrollState = digitalRead(scrollButton);
  byte toggleState = digitalRead(toggleButton);
  if (accesControll == 0)
  {
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0, 0);
    display.print("PIN Eingabe:");
    display.setCursor(0, 12);
    display.print("_");
    display.setCursor(0, 10);
    display.print(pinCode[0]);
    display.setCursor(10, 12);
    display.print("_");
    display.setCursor(10, 10);
    display.print(pinCode[1]);
    display.setCursor(20, 12);
    display.print("_");
    display.setCursor(20, 10);
    display.print(pinCode[2]);
    display.setCursor(30, 12);
    display.print("_");
    display.setCursor(30, 10);
    display.print(pinCode[3]);
    display.display();
    if (toggleState == 1)
    {
      if (digits <= 3)
      {
        digits++;
        delay(100);
      }
      if (digits >= 4)
      {
        if (pinCode[0] == 3 && pinCode[1] == 5 && pinCode[2] == 8 && pinCode[3] == 0)
        {
          display.setCursor(0, 22);
          display.print("Acces Granted");
          accesControll = 1;
          display.display();
          delay(2000);
        }
        else
        {
          display.setCursor(0, 22);
          display.print("Dcces Denied");
          digits = 0;
          display.display();
          delay(2000);
        }
      }

    }
    if (scrollState == 1)
    {
      pinCode[digits]++;
      delay(100);
      if (pinCode[digits] == 10)
      {
        pinCode[digits] = 0;
      }
    }

  }

  //#################

  
  if (accesControll == 1)
  {
    byte toggleState2 = digitalRead(toggleButton);
    if (scrollState == 1)
    {
      scrollValue ++;
      delay(300);
      if (scrollValue == 6)
      {
        scrollValue = 1;
      }
    }
    if (scrollValue == 1)
    {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setCursor(0, 0);
      display.println(site1);
      display.setCursor(100, 0);
      display.println("1/5");
      display.setCursor(0, 10);
      display.print("User:" + user1 + "");
      display.setCursor(0, 20);
      display.print("PW:" + pass1 + "");
      display.display();
      if (toggleState2 == 1)
      {
        Keyboard.print(user1);
        delay(100);
        Keyboard.press(KEY_TAB);;
        delay(100);
        Keyboard.releaseAll();
        delay(100);
        Keyboard.println(pass1);
        delay(100);
        Keyboard.press(KEY_RETURN);;
        delay(100);
        Keyboard.releaseAll();
        delay(500);
      }

    }
    if (scrollValue == 2)
    {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setCursor(0, 0);
      display.println(site2);
      display.setCursor(100, 0);
      display.println("2/5");
      display.setCursor(0, 10);
      display.print("User:" + user2 + "");
      display.setCursor(0, 20);
      display.print("PW:" + pass2 + "");
      display.display();
      if (toggleState2 == 1)
      {
        Keyboard.print(user2);
        delay(10);
        Keyboard.press(KEY_TAB);
        delay(10);
        Keyboard.releaseAll();
        delay(10);
        Keyboard.println(pass2);
        delay(10);
        Keyboard.press(KEY_RETURN);;
        delay(10);
        Keyboard.releaseAll();

        delay(500);
      }
    }
    if (scrollValue == 3)
    {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setCursor(0, 0);
      display.println(site3);
      display.setCursor(100, 0);
      display.println("3/5");
      display.setCursor(0, 10);
      display.print("User:" + user3 + "");
      display.setCursor(0, 20);
      display.print("PW:" + pass3 + "");
      display.display();
      if (toggleState2 == 1)
      {
        Keyboard.print(user3);
        delay(10);
        Keyboard.press(KEY_TAB);
        delay(10);
        Keyboard.releaseAll();
        delay(10);
        Keyboard.println(pass3);
        delay(10);
        Keyboard.press(KEY_RETURN);;
        delay(10);
        Keyboard.releaseAll();
        delay(500);
      }
    }
    if (scrollValue == 4)
    {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setCursor(0, 0);
      display.println(site4);
      display.setCursor(100, 0);
      display.println("4/5");
      display.setCursor(0, 10);
      display.print("User:" + user4 + "");
      display.setCursor(0, 20);
      display.print("PW:" + pass4 + "");
      display.display();
      if (toggleState2 == 1)
      {
        Keyboard.print(user4);
        delay(10);
        Keyboard.press(KEY_TAB);
        delay(10);
        Keyboard.releaseAll();
        delay(10);
        Keyboard.println(pass4);
        delay(10);
        Keyboard.press(KEY_RETURN);;
        delay(10);
        Keyboard.releaseAll();
        delay(500);
      }
    }
    if (scrollValue == 5)
    {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setCursor(0, 0);
      display.println(site5);
      display.setCursor(100, 0);
      display.println("5/5");
      display.setCursor(0, 10);
      display.print("User:" + user5 + "");
      display.setCursor(0, 20);
      display.print("PW:" + pass5 + "");
      display.display();
      if (toggleState2 == 1)
      {
        Keyboard.print(user5);
        delay(10);
        Keyboard.press(KEY_TAB);
        delay(10);
        Keyboard.releaseAll();
        delay(10);
        Keyboard.println(pass5);
        delay(10);
        Keyboard.press(KEY_RETURN);;
        delay(10);
        Keyboard.releaseAll();
        delay(500);
      }
    }

  }

}

Ok...

I guess your program runs and the Oled shows "PIN Eingabe: " or something.

pincode[] has nothing in it, so I'm not sure what "display.print(pinCode[0]);" will do.

Try initialising pincode[] like:

byte pinCode[4]= { '*', '*', '*', '*' };

So your display works, but the rest of your program might not. That's why it never shows anything else.

Work through your program and use Serial.print() with the serial monitor to find out what your values are doing.

Yours,
TonyWilk

TonyWilk:
I guess your program runs and the Oled shows "PIN Eingabe: " or something.

No, if i reconnect my Arduino it shows nothing.

TonyWilk:
Try initialising pincode[] like:

byte pinCode[4]= { '*', '*', '*', '*' };

This doesnt worked either. if i use "pincode[4]" , all array slots will be 0.

I got it working now. I addet a delay at Void Setup .
I dont know why its working but i would guess, that the Arduino was to slow??

void setup()
{
  delay(1000);
  pinMode(scrollButton, INPUT);
  pinMode(toggleButton, INPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
}