Membuat Tampilan Pada LCD Nokia 5110 Menggunakan Arduino

Akses LCD Nokia 5110 dengan Arduino uno

Holaaaa sobat arduino indonesia, dan para penghobi arduino. Kali ini kami akan memberikan tutorial akses LCD Grafik Nokia 5110 menggunakan arduino uno. Lcd 5110 mempunyai 8 pin. yaitu:

RST, CE, Din, Clk, Vcc, Bl, Gnd

 berbeda dengan lcd grafik seperti biasanya yang menggunakan level TTL 5V, 5110 menggunakan level tegangan TTL 3.3V dan VCC 3.3V. Sehingga, jika arduino sobat masih menggunakan tegangan logika 5v, perlu diberi IC 4050.

Skema rangkaiannya..


ini source codenya:

// Nokia 5110 LCD-Display (84x48 Sekolah Robot Indonesia)
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// D7 - Serial clock out (CLK oder SCLK)
// D6 - Serial data out (DIN)
// D5 - Data/Command select (DC oder D/C)
// D4 - LCD chip select (CE oder CS)
// D3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

static const unsigned char PROGMEM sri[] = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00001000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00011000,B00000000,B00000000,B00000000,B00001000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B10000011,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B01111111,B11000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000111,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00001000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00111000,B00000000,B00000000,B00000010,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00011111,B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00011111,B10001000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00001111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000001,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000010,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,B00001000,B00000000,B10000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000010,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B00000000,B00000000,
B00000000,B00000100,B00000000,B00000000,B10000000,B00000000,B00000000,B00000000,B00000100,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00101100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000011,B11000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
};



static const unsigned char PROGMEM logo[]= {                                              // width 40, height 32
B00000000,B00000000,B00000000,B00000000,B01111110,
B00000000,B00000000,B00000000,B00000000,B00101110,
B00000000,B00000000,B00000000,B00000000,B00101010,
B00000001,B11111000,B00000000,B00001111,B10000000,
B00000111,B11111110,B00000000,B00111111,B11100000,
B00011111,B11111111,B10000000,B11111111,B11111000,
B00111111,B00000111,B11000001,B11110000,B11111100,
B00111100,B00000011,B11100011,B11100000,B00111100,
B01111000,B00000000,B11110111,B10000000,B00011110,
B01110000,B00000000,B01110111,B00000110,B00001110,
B11100000,B00000000,B00111110,B00000110,B00000111,
B11100001,B11111000,B00111110,B00011111,B10000111,
B11100001,B11111000,B00011100,B00011111,B10000111,
B11100000,B00000000,B00111110,B00000110,B00000111,
B11110000,B00000000,B00111110,B00000110,B00001111,
B01110000,B00000000,B01110111,B00000000,B00001110,
B01111000,B00000000,B11110111,B10000000,B00011110,
B00111100,B00000011,B11100011,B11100000,B00111100,
B00111111,B00001111,B11000001,B11110000,B11111100,
B00011111,B11111111,B00000000,B11111111,B11111000,
B00000111,B11111100,B00000000,B00111111,B11100000,
B00000001,B11110000,B00000000,B00001111,B10000000,
B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,
B01110011,B11001111,B00100010,B11100100,B01001110,
B10001010,B00101000,B10100010,B01000100,B01010001,
B10001010,B00101000,B10100010,B01000110,B01010001,
B11111011,B11001000,B10100010,B01000101,B01010001,
B10001010,B10001000,B10100010,B01000100,B11010001,
B10001010,B01001000,B10100010,B01000100,B01010001,
B10001010,B00101111,B00011100,B11100100,B01001110,//40x32};
};

static const unsigned char PROGMEM sri_logo[]={
  B00000000,B00000000,B00000000,B00001111,B11111101,B11111100,B11110011,B10000011,B10001110,B11100000,B00000000,
B00000000,B00000000,B00000000,B00011111,B01111101,B11011001,B11111011,B10000011,B10001110,B11100000,B00000000,
B00000000,B00000001,B00000000,B00011000,B01101001,B10110011,B10011001,B10000011,B10001100,B11000000,B00000000,
B00000000,B00000010,B00000000,B00011100,B01110001,B11100011,B00001101,B10000011,B11001111,B11000000,B00000000,
B00000000,B00010010,B00000000,B00000111,B01110001,B11110011,B00001101,B10000111,B11001111,B11000000,B00000000,
B00000000,B00001010,B00000000,B00010011,B01101101,B10111011,B10011001,B10100111,B11001100,B11000000,B00000000,
B01110000,B00000111,B11000000,B00011111,B11111101,B11111101,B11111011,B11111110,B11111110,B11100000,B00000000,
B10011000,B00001111,B00010000,B00011110,B01111001,B11000000,B11100001,B11111110,B01111110,B11100000,B00000000,
B10001000,B00011110,B00000010,B00001100,B10000000,B00000000,B00000000,B00000010,B00000000,B00110000,B00000000,
B01111000,B00100110,B01001110,B00011111,B11100001,B11111100,B11111110,B00011111,B11001111,B11110000,B00000000,
B00011100,B00000010,B00001110,B00011111,B11110011,B11111110,B11111111,B00111111,B11001111,B11110000,B00000000,
B00001110,B01001011,B00011110,B00001110,B01110011,B10001110,B01110111,B00111000,B11101101,B10110000,B00000000,
B00000111,B00000011,B11111110,B00001110,B01110111,B00000111,B01111110,B01110000,B01100001,B10000000,B00000000,
B00000111,B11110111,B11111000,B00001111,B11110111,B00000111,B01111110,B01110000,B01110001,B10000000,B00000000,
B00000001,B11111111,B11110010,B00000111,B11100111,B00000111,B01111111,B01110000,B01110001,B10000000,B00000000,
B00000000,B11111111,B11100010,B00001111,B11000111,B00000111,B01110011,B11110000,B11110001,B10000000,B00000000,
B00000000,B00101111,B10000110,B00001111,B11100111,B10011110,B01110111,B01111001,B11100001,B10000000,B00000000,
B00000000,B01100000,B00001110,B00011111,B01110011,B11111110,B11111111,B00111111,B11000011,B11000000,B00000000,
B00000000,B01110000,B00111110,B00011110,B01110001,B11111100,B11111110,B00011111,B11000011,B11000000,B00000000,
B00000000,B01111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B01111111,B11111110,B00011101,B00011111,B10000011,B00010001,B10111000,B11011101,B11000000,B00000000,
B00000000,B01111111,B11000110,B00011101,B10111111,B11100111,B10011011,B11111101,B11111101,B11000000,B00000000,
B00000000,B00111111,B10000010,B00001001,B11010010,B00111100,B11011101,B00110001,B00001000,B11000000,B00000000,
B00000000,B00000001,B10000000,B00001001,B11110010,B00111000,B01011111,B00111000,B11001001,B11100000,B00000000,
B00000000,B00000001,B10000000,B00001001,B10110010,B00111000,B11011011,B00110000,B01101001,B11100000,B00000000,
B00000000,B00000000,B00000000,B00011101,B10110011,B11101111,B10011011,B00111111,B11111111,B10110000,B00000000,
B00000000,B00000000,B00000000,B00011101,B10010011,B10000111,B00011001,B00111001,B11001111,B00110000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000011,B11111111,B11111111,B11111111,B11100000,
B00000000,B00000000,B00000000,B11111111,B11111111,B11111111,B11111111,B11111111,B11011100,B10000000,B11000000,
B00000000,B00000000,B00000001,B11111111,B11111101,B10110010,B11101010,B00100000,B00000001,B10000000,B11100000,
B00000000,B00000000,B00000001,B10100100,B00010010,B10010010,B11101000,B00100001,B00000001,B11111111,B11110000,
B00000000,B00000000,B00000001,B10100100,B10010010,B10010000,B10101000,B10111111,B11111111,B11111110,B00000000,
B00000000,B00000000,B00000001,B11000100,B10010010,B11111011,B11111111,B11111111,B11000000,B00000000,B00000000,
B00000000,B00000000,B00000001,B10110111,B11111111,B11111111,B11111000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000001,B11111111,B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000001,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
};

void setup()   {

  // Inisialisasi Tampilan
  display.begin();

  // Kontras
  display.setContrast(60);
  display.clearDisplay();   // clears the screen and buffer

}


void loop() {

  display.setTextSize(1); //ukuran teks

  //  (Baris,Kolom,"Teks",warna);

  //set_text(0,0,"Hallo apa kabar?? ",BLACK);
  //delay(500);
  //display.clearDisplay();
  //delay(500);

  //display.drawBitmap(Baris,Kolom,nama_char,pixel_X,pixel_Y,warna);
  display.drawBitmap(0, 0, sri_logo, 84, 39, BLACK);
  display.display();


   }

void set_text(int x,int y,String text,int color){

  display.setTextColor(color); // Warna teks
  display.setCursor(x,y);      // posisi kursor text (Baris, Kolom)
  display.println(text);       // tulisan
  display.display();           // menampilkan hasil
}

------------------------------------------------------------------------------------------------------------
Hasilnya:




------------------------------------------------------------------------------------------------------------
Tips-tips nya bikin tampilan di lcd 5110
1. Ubah gambar dengan format .bmp
2. ukuran pixel gambar <= 84 x 48
3. konversi gambar .bmp manjadi berbentuk kode BINER.
4. Copy kode BINER ke dalam sketch arduino.
5. dengan format "static const unsigned char PROGMEM nama_gambar" (tanpa tanda petik saat diketik pada sketch)
6. Ukuran gambar dengan pixel pada sketch harus sama. misal, gambar ukuran 30 x 20. Maka pada sketch diketik "display.drawBitmap(0, 0, nama_gambar, 30 x 20, BLACK);" (tanpa tanda petik saat diketik pada sketch)


image to binner:
https://github.com/Rodot/BitmapEncoder/blob/master/BitmapEncoder.jar


library pcd8544:
https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

library grafiknya GFX:
https://github.com/adafruit/Adafruit-GFX-Library