click here to enter

OLED display

Kingston hackSpace

OLEDs we have in hackSpace are small displays; they are also known as monochrome displays, they are only about 1” diagonal, but very readable due to the high contrast. This display is made of 128x64 individual white OLED pixels, each one is turned on or off by the micro-controller. Because the display makes its own light, no backlight is required, allowing better energy saving. Briefly saying an OLED display is just better and modified version of and LCD display.

The driver chip SSD1306, communicates via I2C only. 4 pins are required to communicate with the chip in the OLED display, two of which are I2C data/clock pins (SCL and SDA). The OLED and driver require a least 3.3V power supply.

/*  OLED display of text  */#include \"U8glib.h\"#include U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI int offset=0;// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);String source =\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum accumsan arcu nec dui eleifend placerat. Quisque ac leo sed nibh porttitor placerat. Aliquam sodales, quam at hendrerit molestie, metus libero pellentesque est, eu iaculis tellus nibh nec ligula. Praesent ut metus venenatis, molestie lacus quis, sodales ipsum. Curabitur vel convallis nibh. Vivamus ac arcu nec tortor pharetra varius eget quis quam. Sed neque arcu, faucibus id libero et, laoreet placerat dui.\";String dsplay = source.substring(3,7);int x_pos=0;void draw(void) {  //x_pos+=1;  // graphic commands to redraw the complete screen should be placed here    u8g.setFont(u8g_font_unifont);  //u8g.setFont(u8g_font_osb21);  u8g.drawStr( 0, 20, \"Kingston\");  u8g.drawStr( 0, 40, \"hack\");  u8g.drawStr( 0, 60, \"Space\");  }void setup(void) {  lcd.begin(16, 2);  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {    u8g.setColorIndex(255);     // white  }  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {    u8g.setColorIndex(3);         // max intensity  }  else if ( u8g.getMode() == U8G_MODE_BW ) {    u8g.setColorIndex(1);         // pixel on  }  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {    u8g.setHiColorByRGB(255,255,255);  }    draw();}void loop(void) {  // picture loop  lcd.setCursor(0, 0);    lcd.print((source.substring(0+offset, 15+offset)));    if(offset<source.length()){      offset+=1;}else{      offset=0;     }  delay(250);u8g.firstPage();    do {    draw();  } while( u8g.nextPage() );    lcd.clear();}
  • To borrow this component, click here