arduino lcd
Arduino,  Eğitim,  Yazılım

Arduino – LCD5110 Grafik Eğitimi-Kursu

Selam herkese. Bu eğitimde LCD5110 ile ilgili kütüphaneyi ve Bitmap Grafiği ile ilgili fonksiyonları tanıtacağım. Bu dersin ardından gelecek arduino dersinde sizlere Uzay Yarışı (Space Race) oyununu arduino ile nasıl yapacağınızı göstereceğim.


LCD5110 Ekranın Özellikleri ve Bağlantısı

Özellikleri :

  • 84*48 piksel
  • 3.3V Destek

Bağlantılar :

  • VCC -> Arduino 3.3V(veya 5v)
  • BL -> Arduino pin 3 (pwm pin)
  • GND -> Arduino GND
  • CLK (SCLK) -> Arduino pin 8
  • DIN (MOSI) -> Arduino pin 9
  • DC -> Arduino pin 10
  • CE or CS -> Arduino pin 12
  • RST (RESET) -> Arduino pin 11


BMP(Bitmap) File

Bitmap nedir?

Bitmap, görüntü piksellerini bit-bit tanımlayan sıkıştırılmamış bir grafik biçimidir.

Arduino resmi direk algılayamadığı için resmimizi bit bit C diline çevirip arduinoya bildireceğiz.

Adım adım nasıl bir bmp dosyası oluşturduğumuzu göstereceğim.

1-) Bazı grafikler oluşturun. Photo Editor ü kullanmanızı tavsiye ederim

  • Photo Editöre girin
  • “Create new” (yeni oluştur) butonuna tıklayın
  • “width=84” ve “height=48” seçin!(Yükseklik ve genişliği lcd ekranınız ile aynı boyutta seçin)
  • İstediğinizi çizin
  • Çizdiğiniz şekli .jpg formatında kaydedin

2-) JPG formatını BPM formatına çevirin. Convertio yu kullanabilirsin.

  • .jpg dosyanını yükle
  • .bpm ile değiştir
  • kaydet

3-) .c dosyası oluştur. LCD Asistant ı kullanabilirsiniz.

  • Yukarıdaki linkten yükleyin
  • PNG dosyanızı açın
  • .c formatında kaydedin

4-).c dosyanızı arduino kodunuzun bulunduğu dosyaya kaydedin.


Kod Kısmı

Kod kısmında LCD5110 ekranımız için tasarlanmış LCD5110_Graph kütüphanesini kullanacağız. Kod içindeki kodlar hariç daha fazla fonksiyon öğrenmek istiyorsanız linke gidiniz.

#include   //include library

extern uint8_t SAT[];       //describe .c file
int BL=3;                   //describe back light

LCD5110 lcd(8,9,10,11,12);   //LCD5110 name(clk,din,dc,rst,ce);

void setup() {
  pinMode(BL,OUTPUT);
  lcd.InitLCD();            //name.InitLCD();      initilaze the screen
  lcd.setContrast(55);      //name.setContrast();  set contrast (amoung 0 to 127)
}

void loop() {
  analogWrite(BL,330);            
  lcd.clrScr();                   //name.clrScr();   clear the screen
  lcd.drawBitmap(0,0,SAT,84,48);  //name.drawBitmap(x,y,name(.c),width(.c),hight(.c));
  lcd.update();                   //name.update();   update the screen
}

//---------------------BITMAP KODU------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------
#include   //include this library for using PROGMEM
                           //PROGMEM helps using small RAM usage
const unsigned char SAT[] PROGMEM  = {
0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFB, 0xFF,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0xFF, 0xF7, 0xFF, 0x1F, 0x1F, 0x1F, 0x17, 0x1E, 0x1E, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
0xFE, 0xFE, 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, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
};


Yazarımızın diğer yazılarını incelemek için tıklayınız…

Yazar Detayları

Marmara Üniversitesi EEM.

 

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir