작은항해자의 항해

OLED 0.96인치 SPI 통신 본문

IT 이야기/Arduino

OLED 0.96인치 SPI 통신

작은항해자 2014. 11. 25. 13:46

PIN
GND : Power ground
VCC : 3.3V or 5V
D0    : CLK clock

D1    : MOSI data

RST : Reset

DS   : data/command

CS   : chip-select signal



SPI 결선

              D0      D1       DC     CS

uno         13      11        9        10

mega       52      51        49       53


SSD1306 컨트롤러를 사용하며 126x64의 해상도를 가지고 있다.

라이브러리는 https://code.google.com/p/u8glib/ 에서 다운받아 설치.


u8glib 예저 프로그램중 HelloWorld를 열고, 주석처리되어 있는 부분중에 보드와 맞는 침을 찾아 주석을 해제

"U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(13, 11, 10, 9);    // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9"


EX) HelloWorld!


1. LOOP

void loop(void) {
 
// picture loop
  u8g
.firstPage();  
 
do {
    draw
();
 
} while( u8g.nextPage() ); 
 
// rebuild the picture after some delay
  delay
(1000);
}

2. Graphics Output

void draw(void) {

  // graphic commands to redraw the complete screen should be placed here  

  u8g.setFont(u8g_font_unifont);

  u8g.drawStr( 0, 20, "Hello World!"); // x=0, y=20

}


'IT 이야기 > Arduino' 카테고리의 다른 글

ESP8266 Serial Wifi  (0) 2015.05.12
아두이노 나노  (0) 2015.05.12
LCD 라이브러리  (0) 2014.11.25
4 Digital Tube (SH5461AS)  (0) 2014.10.31
온습도 센서  (0) 2014.10.31