Cómo programar y conectar el Display LCD 20X4 con Arduino Uno

Cómo programar y conectar el Display LCD 20X4 con Arduino Uno

En el siguiente tutorial aprenderás como conectar el Display Oled de 128×64 0.96 a un Arduino Uno y programarlo para mostrar imágenes y textos. Los materiales a utilizar son los siguientes:

🔘 DISPLAY OLED LCD 20X4

🔘 ARDUINO UNO STARTER KIT

🔘 CABLES PARA ARDUINO 30CM

¿Display Oled 128×64 SSD1306 como utilizar con Arduino UNO?

Para utilizar el Display Lcd Oled 20×4 con la tarjeta de desarrollo Arduino puedes realizar dos tipos de conexiones, se muestran en las siguientes imágenes:

  • 3.3V del Arduino Uno conectar al pin Vcc del Oled
  • GND del Arduino UNO conectar al pin GND del Oled
  • Pin A4 del Arduino Uno conectar al pin SCL del Oled
  • Pin A5 del Arduino Uno conectar al pin SDA del Oled

2- Segunda conexión:

En las dos imágenes se demuestran las conexiones que debes de hacer con tu Arduino Uno y tu Oled, te preguntaras por qué es posible que funcione con estas 2 tipos de conexiones y es porque esos pines están reservados para que realices una comunicación con SCL y SDA. Si es tu caso y no estás usando Arduino Uno solo busca el pinout de la placa que estés empleando e identifica los pines reservados SCL y SDA y ahí conecta tu Display Oled.

Cuando realices las conexiones de tu Arduino Uno y el Oled abre el IDE de Arduino e importa las librerías de Adafruit GFX graphics y Adafruit_SSD1306, ya que incluiste las librerías tienes que realizar un cambio a la librería Adafruit_SSD1306, solo tienes que buscar la carpeta “libraries” de donde se instaló tu arduino, posteriormente buscar la carpeta de “Adafruit_SSD1306-master” y abrir el archivo “Adafruit_SSD1306.h” con cualquier editor de código, te recomendamos Notepad++, busca la línea de código número 29 y coméntala agregando al principio dos // y descomenta la línea 28, borrando las //. Después debes guardar y cerrar el editor de texto. En la siguiente imagen se muestra como hacerlo:

Por ultimo te comparto este código para que lo puedas probar en tu Oled y verificar su funcionamiento:

#include

< Adafruit_GFX.h >


#include < Adafruit_SSD1306.h >
const unsigned char PROGMEM logo [] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x06,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xc0,0x70,0x80,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0f,0x00,0x30,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0xe0,0x00,0x0c,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x0c,0x00,0x00,0x00,0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x7f,0xff,0xff,0xff,0xc0,0x03,0x00,0x00,0x00,0x30,0x00, 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x04,0x00,0xc0,0x00,0x00,0xec,0x00, 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x13,0x00,0x30,0x00,0x07,0x07,0x00, 0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x60,0xc0,0x0c,0x00,0x30,0x39,0x00, 0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x41,0x98,0x30,0x03,0x03,0x81,0xc1,0x00, 0x00,0x00,0x00,0x01,0x80,0x0f,0xff,0xff,0x07,0x06,0x08,0x00,0xd8,0x0e,0x01,0x00, 0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x1c,0x41,0x86,0x00,0x00,0x70,0x01,0x00, 0x00,0x00,0x00,0x18,0x00,0x40,0x00,0x00,0x66,0x10,0x61,0x80,0x03,0x80,0x01,0x00, 0x00,0x00,0x00,0x3f,0x01,0x00,0x00,0x01,0xe1,0x84,0x19,0x80,0x0c,0x00,0x02,0x00, 0x00,0x00,0x00,0x20,0x1f,0xf8,0x00,0x06,0x18,0x61,0x86,0x00,0x10,0x00,0x06,0x00, 0x00,0x00,0x00,0x20,0x00,0x00,0xf0,0x0b,0x06,0x18,0x78,0x00,0x40,0x00,0x04,0x00, 0x00,0x00,0x00,0x3f,0xc0,0x00,0x06,0x18,0xc1,0x86,0x60,0x01,0x80,0x00,0x08,0x00, 0x00,0x00,0x00,0x00,0x07,0xfc,0x01,0x86,0x30,0x61,0x80,0x06,0x40,0x00,0x10,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x61,0x84,0x1a,0x00,0x18,0x40,0x00,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x8e,0x18,0x61,0x8c,0x00,0x60,0x20,0x00,0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x89,0x86,0x18,0x70,0x01,0x80,0x20,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x61,0x83,0xc0,0x02,0x00,0x10,0x0c,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x18,0x20,0x00,0x02,0x00,0x10,0x30,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x06,0x0c,0x00,0x01,0x00,0x08,0xc0,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x01,0x83,0x00,0x00,0x80,0x0b,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x60,0xc0,0x00,0x80,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x0c,0x00,0x30,0xc0,0x18,0x30,0x00,0x40,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x33,0x00,0x0c,0x30,0x06,0x18,0x00,0x20,0x06,0x00,0x00,0x00, 0x00,0x00,0x00,0x10,0x40,0x80,0x03,0x0c,0x01,0x04,0x00,0x20,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0xef,0x80,0x61,0x00,0xc3,0x01,0x02,0x00,0x10,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x83,0x00,0x1e,0x00,0x30,0xc1,0x01,0x00,0x18,0x01,0x00,0x00,0x00, 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x0c,0x31,0x20,0x80,0x08,0x01,0x00,0x00,0x00, 0x00,0x00,0x01,0x01,0x00,0x00,0x01,0x03,0x0f,0x10,0x40,0x04,0x00,0x80,0x00,0x00, 0x00,0x00,0x01,0x83,0x00,0x00,0x06,0x00,0xc3,0x0c,0x20,0x04,0x00,0x80,0x00,0x00, 0x00,0x00,0x00,0xc6,0x00,0x00,0x18,0x00,0x30,0x02,0x10,0x02,0x00,0x40,0x00,0x00, 0x00,0x00,0x00,0x38,0x00,0x00,0x60,0x00,0x0c,0x03,0x08,0x01,0x00,0x40,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x03,0x0c,0x84,0x03,0x00,0x20,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0xf0,0x42,0x0c,0x00,0x20,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x04,0x00,0x00,0x21,0x30,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x04,0x00,0x00,0x18,0xc0,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x0c,0x40,0x00,0x70,0x00,0x00, 0x00,0x00,0x0f,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x02,0x20,0x03,0x10,0x00,0x00, 0x00,0x00,0x30,0xc0,0x18,0x00,0x00,0x04,0x00,0x00,0x01,0x10,0x0c,0x30,0x00,0x00, 0x00,0x00,0xc0,0x30,0x20,0x00,0x00,0x04,0x00,0x00,0x00,0x88,0x30,0xc0,0x00,0x00, 0x00,0x03,0x00,0x0c,0x80,0x00,0x00,0x0c,0x00,0x00,0x00,0x65,0xc6,0x00,0x00,0x00, 0x03,0xec,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x32,0x18,0x00,0x00,0x00, 0x06,0x18,0x00,0x00,0x00,0x00,0x70,0x40,0x00,0x00,0x00,0x08,0x60,0x00,0x00,0x00, 0x0c,0x08,0x00,0x00,0x00,0x01,0x9d,0x80,0x00,0x00,0x00,0x05,0x80,0x00,0x00,0x00, 0x08,0x08,0x00,0x00,0x00,0x03,0x06,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00, 0x0c,0x18,0x00,0x00,0x00,0x02,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0x10,0x00,0x00,0x00,0x02,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0xe0,0x00,0x00,0x00,0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0xd8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#define OLED_RESET LED_BUILTIN
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error(«Altura incorrecta, cambie en la libreria de Adafruit_SSD1306.h!»);
#endif
void read_temp() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,10);
display.println(«SALUDOS DE»);
display.setCursor(0,32);
display.println(«UNITELECTRONICS»);
display.display();
}
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.drawBitmap(0,0,logo,128,64,1);
display.display(); delay(5000);
}
void loop() {
read_temp();
}

Compila el código y cárgalo a tu Arduino Uno.