I2C 0.96" OLED display module
OLED
noun
noun: OLED; plural noun: OLEDs
- a light-emitting diode containing thin flexible sheets of an organic electroluminescent material, used for visual displays.
- "because OLEDs emit light, they consume significantly less power"
A few example sketches can be found here
And the adafruit tutorial:
To make these examples work you need to have the Adafruit_SSD1306 and the Adafruit_GFX libraries that can be found on github.
There is also this library that works:
I have examples using both libraries.
Like “FAKE CLOCK” using the MicroLCD library
/*************************************************************************
* Demo sketch for MicroLCD library
* Distributed under GPL v2.0
* Copyright (c) 2013-2014 Stanley Huang <stanleyhuangyc@gmail.com>
* All rights reserved.
* For more information, please visit http://arduinodev.com
*************************************************************************/
#include <Arduino.h>
#include <Wire.h>
#include <MicroLCD.h>
int s = 0;
int m = 0;
int h = 12;
//LCD_SH1106 lcd; /* for SH1106 OLED module */
LCD_SSD1306 lcd; /* for SSD1306 OLED module */
const PROGMEM uint8_t smile[48 * 48 / 8] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0x7E,0x7F,0x7F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7E,0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0xF0,0xFC,0xFE,0xFF,0xFF,0xFF,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0xFF,0xFF,0xFF,0xFE,0xFC,0xF0,0xC0,0x00,
0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x1F,0x1F,0x1F,0x3F,0x1F,0x1F,0x02,0x00,0x00,0x00,0x00,0x06,0x1F,0x1F,0x1F,0x3F,0x1F,0x1F,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x30,0xF8,0xF8,0xF8,0xF8,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF8,0xF8,0xFC,0xF8,0x30,0x00,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,
0x00,0x03,0x0F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFC,0xF8,0xF0,0xE1,0xC7,0x87,0x0F,0x1F,0x3F,0x3F,0x3E,0x7E,0x7C,0x7C,0x7C,0x78,0x78,0x7C,0x7C,0x7C,0x7E,0x3E,0x3F,0x3F,0x1F,0x0F,0x87,0xC7,0xE1,0xF0,0xF8,0xFC,0xFF,0xFF,0xFF,0x7F,0x3F,0x0F,0x03,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7E,0xFE,0xFE,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFE,0xFE,0x7E,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
};
void setup()
{
lcd.begin();
}
void loop()
{
lcd.clear();
lcd.setCursor(40, 1);
lcd.draw(smile, 48, 48);
delay(1000);
lcd.clear();
lcd.setCursor(25,1);
lcd.setFontSize(FONT_SIZE_MEDIUM);
lcd.print("FAKE Clock");
delay(1500);
for (h = 1; h<12; h++) {
for (m = 0; m<59; m++) {
for (s = 0; s<59; s++) {
lcd.clear();
lcd.setCursor(35, 3);
lcd.setFontSize(FONT_SIZE_MEDIUM);
lcd.print(h);
lcd.print(":");
if (m < 10) {lcd.print(0);
lcd.print(m); } else {lcd.print(m);}
lcd.print(":");
if (s < 10) {lcd.print(0);
lcd.print(s); } else {lcd.print(s);}
lcd.print("P");
lcd.setCursor(20, 6);
lcd.print("Nov 9, 2014");
delay(1000);
}
}}}
Both libraries are pretty easy to use, and following the examples given pretty easy to modify
Some tricky things to get right is the number of pixels and placement of the “cursor” on the screen.
But one you have done a few you get the hang of where it will be.
No comments:
Post a Comment