Digital input on OLED I2C

Hello!

I want to change my "bulb" screen for an OLED screen in my car. I have 8 bulbs (showing what door is opened, etc) so 8 inputs on Arduino. When you open door 1 it turns on 2 bulbs, one showing the car and other what door is opened. Now what I need is when the door is opened then the voltage comes to digital input pin 1 and this shows car and one door on the screen. When the door 1 and 2 is opened then it shows a car and 2 doors. I have problem programming this because I cannot find any solution to how an input pin can show something on OLED display. Can someone help me? I want something like this: When ignition is on it will show something like Hello greeting on screen, then it will show what door is opened or if there is an error with ABS or if the handbrake is on. All these are normal 12v inputs which I will make 5v for Arduino.

Regards!

if (digitalRead(aPin) == HIGH)
{
  //show picture on screen
}

Yes, OK, but how to show picture? What library to use for this?

Scortexx:
Yes, OK, but how to show picture? What library to use for this?

Which display have you got ?

UKHeliBob:
Which display have you got ?

0.96 ssd1306 i2c OLED I think

We need to know exactly.

Can you please provide a link to where you got it ?

From Ebay but I don't have the exact article.

I have added Adafruit_SSD1306.h and it works but I cannot put anything in void loop that will work. If I put

if (digitalRead(pin2) == HIGH)
{
Display.setTextSize(2);
  Display.setTextColor(WHITE, BLACK);
  Display.setCursor(15, 10);
  Display.println("Test");
Display.display();
}

it will just show "Test", it goes over digital read input. I have set that pin 2 is and input and initialized it as pin 2 but it won't work.

it will just show "Test", it goes over digital read input.

Please explain.

Please post your code

AWOL:
Please post your code

And pictures of your OLED output showing the bad behavior.

Scortexx:
I have added Adafruit_SSD1306.h and it works

If only the Adafruit_SSD1306.h library came with examples all ready for you to build from.

Oh, wait. They DO!

Yes, I have took the example and tried to change what I need and came up with the code. But it just shows the "Test" on the screen without me getting 5v to pin 2.


[code#include <SPI.h>
#include <Wire.h>

#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

const int pin2 = 2;

int buttonState = 0; 


void setup()   {

Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
  
  display.clearDisplay();
  display.display();
  delay (1000);

 pinMode(pin2, INPUT);

  
}


void loop() {
buttonState = digitalRead(pin2);

if (digitalRead(pin2) == HIGH)

{
  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Test");
  display.display();

}

}
]

Perhaps pin 2 is floating.

Yes, it was a floating pin! I had the same problem before but didn't cross my mind!

No it works great with input_pullup but I need to have a positive input for digital pin?