Changing code from OLED to LCD

I have a code that is used for detecting movement behind walls. It uses a DMS (Digital Microwave Sensor). The blueprint I use used a OLED Display and Arduino Nano, I only have a LCD Display and an Arduino Uno. I don't even know if the type of Arduino matters in any way, but I don't know how I should change the code for the different type of display that I have.
For convenience the website I found this project on is: "Electronic Clinic, microwave sensor with arduino for humans and objects detection behind walls."
Here's the Code:

#include <SPI.h>
#include <MsTimer2.h>           //Timer interrupt function library
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
 
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


int pbIn = 0;                    // Define interrupt 0 that is digital pin 2
int ledOut = 13;                 // Define the indicator LED pin digital pin 13
int number=0;                    //Interrupt times
volatile int state = LOW;         // Defines the indicator LED state, the default is not bright

void setup()
{
     Serial.begin(9600);
     pinMode(ledOut, OUTPUT);//
     attachInterrupt(pbIn, stateChange, FALLING); // Set the interrupt function, interrupt pin is digital pin D2, 
                                                   //interrupt service function is stateChange (), 
                                                   //when the D2 power change from high to low , the trigger interrupt.
     MsTimer2::set(3000, Handle); // Set the timer interrupt function, running once Handle() function per 1000ms
     MsTimer2::start();//Start timer interrupt function

    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display.clearDisplay();
    display.display();
}

void loop()
{
 display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,5);
 display.println("status: ");

  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setCursor(0,30);
 display.println(number);

  display.display(); 
  display.clearDisplay();
  delay(10);

 }


void stateChange()  //Interrupt service function
{
  number++;  //Interrupted once, the number + 1

}

void Handle()   //Timer service function
{
number = 0;
}

I'd greatly appreciate if someone could help me with this.

KoenV.

have you already got a different display?
if so give a link or a photo?
if not what are you looking for? size, resolution, etc?

You just need the appropriate library for the LCD, which is apparently secret. There will be a hello world type example therein, which is all you need. Uno and standard Nano are functionally the same, and use the same code.

1 Like

OLED uses pixels to draw the characters, but generally has eight lines and twenty characters for size-1 text. (total 160 characters).

LCD has two lines of 16 characters. (total 32 characters).

You will need to be selective in the data printed to the LCD.


t
Here are the photos

That is a plain-vanilla parallel drive LCD probably using the standard liquid crystal library, not the liquid crystal I2C library alluded to above. The supplier should also have the library, although it may be included in the IDE these days.

Nano and Uno are very similar, the code will probably run on either without any modification. (Assuming you mean Nano V3 and Uno R3.)

So get an OLED and you should be good to go.

Your LCD is not a good substitute for the OLED, and even if that were not so, the code changes required would be beyond your expertise at this stage. Keep the LCD for another project.

Ok I will

Thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.