-
Notifications
You must be signed in to change notification settings - Fork 3
OLED
MarcG edited this page Feb 22, 2015
·
1 revision
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)
#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);
}Como generar el código para las imagenes: Asistente LCD para bipmaps


