Hướng dẫn sử dụng màn hình OLED 0.96 inch với Arduino

Xin chào các bạn! Hôm nay chúng ta sẽ cùng nhau “vọc” cái màn hình OLED 0.96 inch. Nhưng đầu tiên ta hãy cùng tìm hiểu công nghệ OLED là gì?

Màn hình OLED là gì?

  

        Trong thời gian gần đây công nghệ hiển thị OLED đang được nhắc đến nhiều và nổi lên như là một ứng cử viên sáng giá thay thế cho công nghệ LCD. Organic light-emitting diode (OLED) là các thiết bị thể rắn cấu tạo từ các tấm phim mỏng làm từ các hợp chất hữu cơ. Tấm phim này sẽ phát ra ánh sáng khi được cung cấp điện năng. OLED có thể tạo ra những hình ảnh sáng và rõ nét hơn nhưng lại tiêu thụ ít điện năng hơn các công nghệ màn hình LED (Light-Emitting Diode: Diode phát quang) hay LCD (Liquid Crystal Display: Màn hình tinh thể lỏng) hiện tại.

+ Ưu điểm của OLED

+ Nhược điểm của OLED

 

Mlab sẽ hướng dẫn bạn sử dụng màn hình màn hình OLED 0.96 inch với Arduino

OLED 0.96inch (B)

Thông số kỹ thuật

Driver

SSD1306

Giao tiếp

3-wire SPI, 4-wire SPI, I2C

Độ phân

128*64

Kích thước màn h

0.96 inch

Màu sắc

Vàng, xanh

Góc hiện thị

>160°

Kích thức

33mm*33.50mm

Nhiệt độ hoạt động (℃)

-20~70

Nhiệt độ bảo quản. (℃)

-30~80

Cấu hình phần cứng giao tiếp

Giao tiếp

BS1/BS0

DIN

CLK

3-wire SPI

0/1

MOSI

SCLK

4-wire SPI

0/0

I2C

1/0

SDA

SCL

Để thay đổi trạng thái 0/1 của BS1 và BS0 ta thay đổi vị trí của 2 con trở 0 Ohm được khoanh đỏ trên hình.

Link tham khảo sản phẩm:

http://mlab.vn/1716100-oled-0-96inch-b.html

http://www.waveshare.com/wiki/0.96inch_OLED_(B)

Sơ đồ kết nối


Trong bài viết này mình sẽ sử dụng giao tiếp 4-wire SPI:

Vcc

3.3V~5V

GND

GND

Din (D1)

11

CLK (D0)

13

CS

10

DC (A0)

9

RES

8

Cách cover ảnh sang Bitmap


Bước 1: Mở ảnh bằng Paint. Chọn Rize, bỏ tích Maitain aspect ratio, chỉnh kích thước ảnh thành 128x64.

 

Bước 2: Lưu file với định dạng .bmp

Ta sẽ có bước ảnh như thế này:

Bước 3:

Tải LCD Assistant (link download: http://k1.arduino.vn/img/2017/03/03/0/3638_123450-1488536223-0-lcdassistant.zip)

Tìm file vừa lưu mở LCD Assistant. Chọn file, chọn file load, tích mục horizontal, Width 128, height 64.

Xong ta chọn file, chọn save out 

Khi ‘Save out’ ra bạn nhớ lưu file với định dạng “.c”.

Bước 4:

Sử dụng Notepad++ để mở file vừa lưu. Copy phần biến và paste vào sketch Arduino.

Lưu ý: Bạn nhớ thêm “PROGMEM” vào sau tên của bitmap.

 

Lập trình


Trước khi đi vào chương trình chính ta sẽ cùng tìm hiểu về thư viện U8glib. Tải thư viện

https://bintray.com/olikraus/u8glib/Arduino

Tải về, giải nén paste vào thư mục libraries của thư mục cài đặt Arudino IDE.

Code:

#include "U8glib.h"

// Thiết lập phần cứng

U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9, 8);  // SW SPI Com: (D0)SCK = 13, (D1)SDA,MOSI = 11, (CS)CS = 10, (DC)A0 = 9 (RES)RES = 8

 

int frame =0;

 

const uint8_t mlab[] PROGMEM = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,

0x00, 0x0F, 0xF0, 0x07, 0xF8, 0x03, 0xFC, 0x00, 0x00, 0x1F, 0x80, 0x00, 0xFE, 0x1F, 0x00, 0x00,

0x00, 0x3F, 0xFC, 0x1F, 0xFE, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0xF0, 0x00, 0xFE, 0x7F, 0xE0, 0x00,

0x00, 0x7F, 0xFF, 0x7F, 0xFF, 0x03, 0xFC, 0x00, 0x03, 0xFF, 0xFC, 0x00, 0xFE, 0x7F, 0xF8, 0x00,

0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0xFC, 0x00, 0x07, 0xFF, 0xFE, 0x00, 0xFE, 0x7F, 0xFC, 0x00,

0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0xFC, 0x00, 0x0F, 0xFF, 0xFF, 0x00, 0xFE, 0x7F, 0xFE, 0x00,

0x01, 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, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x01, 0xE0, 0x00, 0x80, 0x00, 0x08, 0x08, 0x00, 0x10, 0x38, 0x01, 0x00, 0x6C, 0x00, 0x00, 0x00,

0x01, 0x00, 0x00, 0x80, 0x00, 0x08, 0x08, 0x00, 0x10, 0x68, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00,

0x01, 0x05, 0x98, 0xB8, 0x70, 0xE8, 0xE8, 0xE1, 0xD0, 0x60, 0x71, 0x22, 0x64, 0x71, 0x71, 0x80,

0x01, 0xE6, 0xEC, 0xCC, 0x89, 0x99, 0x99, 0x13, 0x30, 0x30, 0x99, 0x22, 0x6C, 0x99, 0x92, 0x00,

0x01, 0x04, 0x44, 0x85, 0x89, 0x09, 0x09, 0x1A, 0x10, 0x19, 0x89, 0x22, 0x4D, 0x09, 0x13, 0x00,

0x01, 0x04, 0x44, 0x85, 0x81, 0x09, 0x0B, 0x02, 0x10, 0x0D, 0x8D, 0x22, 0x4D, 0x09, 0x11, 0x80,

0x01, 0x04, 0x44, 0xCC, 0x81, 0x99, 0x19, 0x03, 0x30, 0x4C, 0x89, 0x32, 0x4D, 0x89, 0x10, 0x40,

0x01, 0xE4, 0x44, 0xF8, 0xF8, 0xF8, 0xF8, 0xF1, 0xF0, 0x38, 0xF1, 0x1C, 0x6C, 0xF1, 0x13, 0x80,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

};

const unsigned char thich_an_my_logo[] PROGMEM = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x61, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x02, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x03, 0x18, 0x00, 0x00, 0x42, 0x10, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0x00, 0x22, 0x11, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x4C, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x0C, 0x80, 0x00, 0x98, 0x44, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x01, 0x10, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x02, 0x08, 0x84, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x01, 0x00, 0x84, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x3F, 0xA0, 0x88, 0xF9, 0x86, 0x03, 0x04, 0x10, 0x60, 0xC8, 0x20, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x20, 0x89, 0x01, 0x86, 0x02, 0x87, 0x10, 0x50, 0xC4, 0x40, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x30, 0x8A, 0x01, 0x86, 0x04, 0x85, 0x90, 0x51, 0x42, 0x80, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x20, 0x8A, 0x01, 0x86, 0x0C, 0xC4, 0xD0, 0x4A, 0x41, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x20, 0x89, 0x01, 0x86, 0x08, 0x44, 0x70, 0x4E, 0x41, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x20, 0x88, 0xF9, 0x86, 0x10, 0x24, 0x30, 0x44, 0x21, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

};

void draw(void) {

  if(frame==0){

   u8g.setFont(u8g_font_osb21);      // cài font cho chuỗi

   u8g.drawStr( 15, 42, "mlab.vn");  // Viết chuôi tại vị trí x=15, y=42

  }

  else if (frame == 1)

   u8g.drawBitmapP( 0, 0, 16, 64, mlab); // vẽ bitmap với tọa độ x=0, y=0, kích thước: rộng=16*8; cao=64

  else if(frame == 2){

   u8g.setFont(u8g_font_unifont);

   u8g.drawStr( 10,40 , "OLED test 0.96'");

  }

   else if(frame == 3)

   u8g.drawBitmapP( 0, 0, 16, 64, thich_an_my_logo);

}

void setup(void) {

    u8g.setColorIndex(1);         // pixel on

}

void loop(void) {

  // "picture loop": vong lặp hiển thị

  u8g.firstPage(); 

  do {

    draw();

  } while( u8g.nextPage() );

 frame ++;

 if(frame>3)

 frame = 0;

delay(3000);

}

 

Kết quả


Nếu có bất kì khó khăn gì các bạn hãy để lại ở phần bình luận phía dưới, chúng tôi sẽ giải đáp những thắc mắc cho các bạn. Chúc các bạn thành công!

 

Viết đánh giá

Họ và tên:


Đánh giá của bạn: Lưu ý: Không hỗ trợ HTML!

Bình chọn: Dở            Hay

Nhập mã bảo vệ: