[WAT-OLED 128×64] I2C 방식의 128×64 OLED

[WAT-OLED 128×64] I2C 방식의 128×64 OLED

WAT-OLED 128×64 는 I2C방식의 128×64 픽셀의 OLED 입니다.

 

 

  • 드라이버 IC : SSD1306 : Datasheet (PDF)
  • 입력 전압: 3.3 - 5.0V
  • 해상도:128 x 64 픽셀
  • 사이즈 : 0.96 inch
  • 인터페이스:I2C
  • 색상 : Yellow Blue  (윗쪽은 Yellow, 아래 쪽은 Blue ) 하단 그림 참조
  • Dimensions: 27.3mm x 27.3mm x 11 mm (H) 

 

 

 

제품 이미지

 

 

 

Arduino UNO R3  예제

부품 목록
부품명 WAT-OLED 128×64 I2C

기능 128 x 64 OLED
수량 1
판매처 https://kit128.com/goods/view?no=384

 

부품명 아두이노 UNO R3

Arduino UNO R3

기능 아두이노 모듈
수량 1
판매처 https://kit128.com/goods/view?no=337

 

 

연결

 

Arduino UNO R3 모듈 WAT-OLED 128×64
5V VCC
GND GND
A5(SCL) SCL
A4(SDA) SDA

 

 

소스코드

최신 소스코드는 [파일]=>[예제]=> [WhiteAT_UNO]=>[WAT-OLED 128×64]  => [WAT_OLED 128×64] 에 있습니다.

(https://docs.whiteat.com/?page_id=5449  참조)

 

/*
[WAT-OLED 128x64]I2C 방식 128x64 OLED
UNO 와 [WAT-OLED 128x64]I2C 방식 128x64 OLED 예제

UNO R3 : https://kit128.com/goods/view?no=337
[WAT-OLED 128x64] I2C  128x64 OLED: https://kit128.com/goods/view?no=384

자료: http://whiteat.com/Arduino
*/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 oled(OLED_RESET);

#define LOGO_GLCD_HEIGHT 48 
#define LOGO_GLCD_WIDTH  48 
static const unsigned char PROGMEM logo_glcd_bmp[] =
{ 
0b00000000, 0b00000000, 0b00000111, 0b11100000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b11111111, 0b11111111, 0b00000000, 0b00000000,
0b00000000, 0b00000011, 0b11111111, 0b11111111, 0b11100000, 0b00000000,
0b00000000, 0b00001111, 0b11111111, 0b11111111, 0b11111000, 0b00000000,
0b00000000, 0b00011111, 0b11111111, 0b11111111, 0b11111100, 0b00000000,
0b00000000, 0b01111111, 0b11111111, 0b11111111, 0b11111111, 0b00000000,
0b00000000, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b10000000,
0b00000001, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11000000,
0b00000011, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11100000,
0b00000111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11110000,
0b00000111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11110000,
0b00001111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111000,
0b00011111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111100,
0b00011111, 0b10000111, 0b11000011, 0b11100001, 0b11111111, 0b11111100,
0b00111111, 0b10000111, 0b11000001, 0b11100001, 0b11111111, 0b11111110,
0b00111111, 0b11000111, 0b10000001, 0b11100001, 0b11111111, 0b11111110,
0b01111111, 0b11000011, 0b10000001, 0b11100011, 0b11111111, 0b11111110,
0b01111111, 0b11000011, 0b10000001, 0b11100011, 0b11111111, 0b11111111,
0b01111111, 0b11000011, 0b10000000, 0b11000011, 0b11111111, 0b11111111,
0b01111111, 0b11000011, 0b00011000, 0b11000000, 0b00111111, 0b11111111,
0b01111111, 0b11100011, 0b00011000, 0b11000000, 0b00111111, 0b11111111,
0b11111111, 0b11100001, 0b00011000, 0b01000000, 0b00011111, 0b11111111,
0b11111111, 0b11100000, 0b00011000, 0b01000000, 0b00011111, 0b11111111,
0b11111111, 0b11100000, 0b00011100, 0b00000001, 0b00011111, 0b11111111,
0b11111111, 0b11110000, 0b00111100, 0b00000001, 0b10001111, 0b11111111,
0b11111111, 0b11110000, 0b00111100, 0b00000011, 0b10001111, 0b11111111,
0b11111111, 0b11110000, 0b00111110, 0b00000011, 0b10001111, 0b11111111,
0b01111111, 0b11110000, 0b00111110, 0b00000011, 0b10000111, 0b11111111,
0b01111111, 0b11110000, 0b01111110, 0b00000011, 0b11000111, 0b11111111,
0b01111111, 0b11111000, 0b01111110, 0b00000111, 0b11000111, 0b11111111,
0b01111111, 0b11111111, 0b11111111, 0b10000000, 0b00000011, 0b11111111,
0b01111111, 0b11111111, 0b11111111, 0b10000000, 0b00000011, 0b11111111,
0b00111111, 0b11111111, 0b11111111, 0b10000000, 0b00000001, 0b11111110,
0b00111111, 0b11111111, 0b11111111, 0b00001111, 0b11100001, 0b11111110,
0b00111111, 0b11111111, 0b11111111, 0b00001111, 0b11100001, 0b11111110,
0b00011111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111100,
0b00011111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111000,
0b00001111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111000,
0b00000111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11110000,
0b00000111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11110000,
0b00000011, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11100000,
0b00000001, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11000000,
0b00000000, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b10000000,
0b00000000, 0b01111111, 0b11111111, 0b11111111, 0b11111111, 0b00000000,
0b00000000, 0b00011111, 0b11111111, 0b11111111, 0b11111100, 0b00000000,
0b00000000, 0b00000111, 0b11111111, 0b11111111, 0b11110000, 0b00000000,
0b00000000, 0b00000011, 0b11111111, 0b11111111, 0b11000000, 0b00000000,
0b00000000, 0b00000000, 0b01111111, 0b11111111, 0b00000000, 0b00000000 };

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   
{
	Serial.begin(115200);
	randomSeed(analogRead(0));

	oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);

 
	oled.display();
	delay(2000);
	oled.clearDisplay();



	/*
 	oled.setTextSize(2);
	oled.setTextColor(WHITE);
	oled.setCursor(0,0);
	oled.println(F("KIT128.com"));

	oled.setTextSize(1);
	oled.setTextColor(WHITE);
	oled.setCursor(50,16);
	oled.println(F("WhiteAT.com"));
	oled.setCursor(50,32);
	oled.println(F("help@"));
	oled.setCursor(50,44);
	oled.println(F("kit128.com"));

	oled.drawBitmap(0, 16,  logo_glcd_bmp,LOGO_GLCD_WIDTH, LOGO_GLCD_HEIGHT,   1);
	oled.display();
	delay(2000);
	oled.clearDisplay();
	*/
}

void loop() 
{
	testShape();
}

class Shape
{
public:
	Shape()
	{
		newShape();
	}
	Adafruit_SSD1306 *oled;
	void SetOLED(Adafruit_SSD1306 *_led){ oled = _led; }

	uint8_t type = 0;
	uint8_t speed = 1;
	uint8_t x = 0, y = 0;

public:
	void newShape()
	{
		type = random(0, 3);
		x = random(5, 60);
		y = 16;

		speed = random(2, 10);
	}

	void draw(uint8_t _y, uint8_t color) 
	 {         
		switch (type)
		{
		case 0:
			oled->fillRect(x, _y, 10, 10, color);
			break;
		case 1:
			oled->fillCircle(x, _y, 5, color);
			break;
		case 2:
			oled->fillTriangle(x - 5, y + 1, x + 5, y + 1, x, y - 7, color);
			break;

		}
		oled->display();
	}

	void earase(uint8_t _y) 
	{
		draw(_y, 0);
	}

	bool moveDown()
	{
		y += speed;
		if (y >= SSD1306_LCDHEIGHT)
		{
			return false;
		}

		draw(y, 1);
		return true;
	}
};

Shape shape;
int shapecount = 0;
void testShape(void)
{
	shape.SetOLED(&oled);

	oled.clearDisplay();
	oled.setTextSize(1);
	oled.setTextColor(WHITE);
	oled.setCursor(0, 0);
	oled.println(F("Count:"));
	oled.setTextSize(2);
	oled.setCursor(40, 0);
	oled.println(shapecount);
	if (shape.moveDown())
	{

	}
	else
	{
		shape.newShape();
		shapecount++;
	}

	delay(200);
}

 

결과

로고를 보여주고,

사각형, 삼각형,원 모양이 랜덤으로 떨어지며 카운터가 증가합니다.

 

 

FAQ

화면에 이미지를 넣고 싶은데 어떻게 소스코드로 변환하나요?

이미지를 소스코드(TEXT)로 변환해 주는 툴 (ImageToText)

아두이노 우노 RAM 용량이 작은데 이미지가 들어가나요?

이미지 같이 고정 데이터의 경우 flash 영역을 사용하면 됩니다.

아두이노에서는 아래와 같은 형식으로 데이터를 선언하면 flash 영역을 사용하게 되어 RAM 용량과는 크게 상관이 없게 됩니다.

static const unsigned char PROGMEM aa[]= {1,2,3,4,};

 

 

 

제품 구매

[WAT-OLED 128×64] I2C 방식의 128×64 OLED 는 https://kit128.com/goods/view?no=384 에서 구매하실 수 있습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다