Go Down

Topic: LED LCD convert code to OLED 0,96 SERIAL LCD (Read 238 times) previous topic - next topic

lupengr29

Jul 11, 2019, 08:33 am Last Edit: Jul 11, 2019, 10:46 am by lupengr29
I have a main code with a 1602 lcd .... I want to change this lcd with a smaller OLED 0,96 SERIAL

Any help with the code above? And about the pinout connections?


Code: [Select]


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);/// REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5 PIN, D6 PIN, D7 PIN

char ADCSHOW[5];//initializing a character of size 5 for showing the ADC result

void setup()

{

 // set up the LCD's number of columns and rows:

lcd.begin(16, 2);

}



void loop()

{

            lcd.print("FluxDensity");//showing name

               lcd.setCursor(0, 1);//move to second line

               lcd.print("(in Gauss):");// showing units

               String ADCVALUE = String((analogRead(A0)-515)/3.76);

/* Now since the default reference if 5V and resolution is 10bit so for every 5/1024 = 5mV, we get one increment is count, The sensor provides increment voltage of 1.3V for every 1Gauss increment if field.

So we need to divide ADC value by 3.76 for getting the gauss value, now the 0 gauss output of sensor is 2.5V so we need to subtract that first. To hold a 0V read at 0Gauss field. */

               // Convert the reading to a char array

               ADCVALUE.toCharArray(ADCSHOW, 5);

               lcd.print(ADCSHOW);//showing the field strength value

               lcd.print("G   ");

               lcd.setCursor(0, 0);// set the cursor to column 0, line 0

}


septillion

Please edit you post to use code tags.

But you can start by dropping the whole String nonsense ;)

And in my opinion U8g2 is the best library for that screen. Documentation is also pretty good. And your code isn't to complicated so you should be able to figure that out :)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

lupengr29

Please edit you post to use code tags.

But you can start by dropping the whole String nonsense ;)

And in my opinion U8g2 is the best library for that screen. Documentation is also pretty good. And your code isn't to complicated so you should be able to figure that out :)
I am searching and found out that I can change the first 3 line with the library you said... but at the code I have issues and I cannot have a working result :(

If someone know the U8g2 library it would be perfect to help me about the syntax and the changes...

Th oled lcd that I want to change is this

https://www.ebay.com/itm/Display-OLED-lcd-led-0-96-128x64-12864-blu-per-Arduino-I2C-IIC-tipo-SSD1306/223202233477?hash=item33f7e3cc85:g:hlMAAOSwhyRb0HlW

About the PCB connection we have:

GND/VCC know pinouts and SCL and SDA at A5/A4 Analog Outputs

septillion

I don't really know what you mean by "can change the first 3 line with the library".

Start by looking at the examples of the U8g2 library and try to get them to work.

Small tip, not all of those displays are sold with the same address set. With a I2C scanner sketch (Google it) you can get the correct address of the screen. Just use that in the examples and see if it works.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

david_prentice

Your OLED will have I2C address = 0x3C
It should work fine with U8g2lib examples.   Just select the correct constructor e.g.
Code: [Select]

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);


David.

lupengr29

Your OLED will have I2C address = 0x3C
It should work fine with U8g2lib examples.   Just select the correct constructor e.g.
Code: [Select]

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);


David.
I will try it and I will post the result :D

Go Up