부품 중 128X64 1.3 인치 LCD  I2C 모듈(SH1106)에 u8g2사용해서 한글 사용하자

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

void setup(void) {
  u8g2.begin();
  u8g2.enableUTF8Print();		// enable UTF8 support for the Arduino print() function
}

void loop(void) {
  u8g2.setFont(u8g2_font_unifont_t_korean1);  
  u8g2.setFontDirection(0);
  u8g2.firstPage();
  do {
    u8g2.setCursor(0,15);
    u8g2.print("Hello World!");
    u8g2.setCursor(0, 31);
    u8g2.print("안녕 세상");
    u8g2.setCursor(0, 44);
    u8g2.print("3번 라인");
    u8g2.setCursor(0, 60);
    u8g2.print("번째 줄");
  } while ( u8g2.nextPage() );
  delay(1000);
}
728x90

+ Recent posts