Skip to content
MarcG edited this page Feb 22, 2015 · 1 revision

OLED screen (SSD1306):

El hardward:

UG-2864HSWEG01 Datasheet

UG-2864HSWEG01 User Guide

SSD1306 Datasheet

Llibreria Adafruit:

Adafruit_SSD1306

Adafruit-GFX-Library

Llibreria alternativa:

GOFi2cOLED Library

Como conectar?

OLED schem

GND goes to ground

Vin goes to 5V

Data to I2C SDA (on the Uno, this is A4 on the Mega it is20 and on the Leonardo digital 2)

Clk to I2C SCL (on the Uno, this is A5 on the Mega it is21 and on the Leonardo digital 3)

RST to digital 4 (you can change this pin in the code, later)

Código ejemplo:

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

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);
}


void loop() {
  // Clear the buffer.
  display.clearDisplay();

  // draw a single pixel
  display.drawPixel(10, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw one line
  display.drawLine(0, 0, display.width()/2, display.height()-1, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw one circle
  display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hola Makers");
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println("Hola Makers");
  display.display();
  delay(2000);
}

Que es SPI?

SPI

Que es I2C?

I2C

Demo pantalla OLED:

Solución

Como generar el código para las imagenes: Asistente LCD para bipmaps

Bonus code: Flappy bird

Solución

<<< Volver

HOME

  • [Instalación y familiarización con el IDE] (Instalación y familiarización con el IDE)
  • [Bases de C] (Bases de C)
  • [Ejercicios] (Ejercicios)
  • [Programación de la Matriz de LEDs] (Programación de la Matriz de LEDs)

Clone this wiki locally