OLED Kullanım Kılavuzu SSD1306 & SH1106

Bu yazıda üç kütüphaneyi sensörlerden gelen verileri işlemek için kullanacağım.

Bu kütüphaneler:

  • Adafruit  / #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
  • HCuOLED / #include “HCuOLED.h”
  • u8glib /  #include “U8glib.h”

Eğer sensörlerden gelen değerler belirli bir kıstasın yukarısında veya aşağısındaysa bu değerlerin rakamları ekranda siyah beyaz gözükecek. Yani arka planı siyah, yazısı beyaz olacak.

Buna göre

  • Kodun kolaylığı
  • Kullandığı hafıza

bakımından bu kütüphaneyi kıyaslayabilmeyi umuyorum.

Adafruit  Kütüphanesi

UNO ile :

Sketch uses 13,560 bytes (42%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,174 bytes (57%) of dynamic memory, leaving 874 bytes for local variables. Maximum is 2,048 bytes.

Adafruit malesef SH1106 ile sağlıklı çalışmıyor. Üst kısımlarda kayma oluyor. Birkaç yerde bahsedilmiş ama çözümü yok gibi.

HCuOLED Kütüphanesi

 

 

 

u8glib Kütüphanesi

https://github.com/olikraus/u8glib/issues/404

 

setColorIndex

setDefaultBackgroundColor

setCursorColor

https://github.com/olikraus/u8glib/wiki/tstring

https://github.com/olikraus/u8glib/wiki/userreference#setcolorindex

https://github.com/olikraus/u8glib

https://github.com/olikraus/u8glib/wiki/tmenu

https://code.google.com/archive/p/u8glib/wikis

 

 

[[code]]czo4Mjg6XCIjZGVmaW5lIE1FTlVfSVRFTVMgNA0KY2hhciAqbWVudV9zdHJpbmdzW01FTlVfSVRFTVNdID0geyBcXFwiRmlyc3QgTGluZXtbJiomXX1cXFwiLCBcXFwiU2Vjb25kIEl0ZW1cXFwiLCBcXFwiMzMzMzMzM1xcXCIsIFxcXCJhYmNkZWZnXFxcIiB9Ow0KDQp2b2lkIGRyYXdfbWVudSh2b2lkKSB7DQp7WyYqJl19ICB1aW50OF90IGksIGg7DQogIHU4Z191aW50X3QgdywgZDsNCiAgdThnX1NldEZvbnQoJmFtcDt1OGcsIHU4Z19mb250XzZ4MTMpO3tbJiomXX0NCiAgdThnX1NldEZvbnRSZWZIZWlnaHRUZXh0KCZhbXA7dThnKTsNCiAgdThnX1NldEZvbnRQb3NUb3AoJmFtcDt1OGcpOw0KICBoe1smKiZdfSA9IHU4Z19HZXRGb250QXNjZW50KCZhbXA7dThnKS11OGdfR2V0Rm9udERlc2NlbnQoJmFtcDt1OGcpOw0KICB3ID0gdThnX0dldFd7WyYqJl19aWR0aCgmYW1wO3U4Zyk7DQogIGZvciggaSA9IDA7IGkgJmx0OyBNRU5VX0lURU1TOyBpKysgKSB7ICAgICAgICAvLyBkcmF3IGFsbHtbJiomXX0gbWVudSBpdGVtcw0KICAgIGQgPSAody11OGdfR2V0U3RyV2lkdGgoJmFtcDt1OGcsIG1lbnVfc3RyaW5nc1tpXSkpLzI7DQogICAge1smKiZdfXU4Z19TZXREZWZhdWx0Rm9yZWdyb3VuZENvbG9yKCZhbXA7dThnKTsNCiAgICBpZiAoIGkgPT0gbWVudV9jdXJyZW50ICkgeyAgICB7WyYqJl19ICAgICAgICAgICAvLyBjdXJyZW50IHNlbGVjdGVkIG1lbnUgaXRlbQ0KICAgICAgdThnX0RyYXdCb3goJmFtcDt1OGcsIDAsIGkqaHtbJiomXX0rMSwgdywgaCk7ICAgICAvLyBkcmF3IGN1cnNvciBiYXINCiAgICAgIHU4Z19TZXREZWZhdWx0QmFja2dyb3VuZENvbG9yKCZhbXA7e1smKiZdfXU4Zyk7DQogICAgfQ0KICAgIHU4Z19EcmF3U3RyKCZhbXA7dThnLCBkLCBpKmgsIG1lbnVfc3RyaW5nc1tpXSk7DQogIH0NCn0NClwie1smKiZdfTt7WyYqJl19[[/code]]

 

Greiman Kütüphanesi

https://github.com/greiman/SSD1306Ascii

SOFT SPI

 

// Simple software SPI test for ebay 128×64 oled.

// pin definitions
#define OLED_DC 50
#define OLED_CS 53
#define OLED_CLK 52
#define OLED_DATA 51
#include “SSD1306Ascii.h”
#include “SSD1306AsciiSoftSpi.h”

SSD1306AsciiSoftSpi oled;
int Iceri_Sicaklik_Alt_Value = 30;
int Iceri_Sicaklik = 45;

int Iceri_Sicaklik_Tavan_Value = 60;
int Iceri_Nem_Alt_Value = 30;
int Iceri_Nem = 40;
int Iceri_Nem_Tavan_Value = 60;
int Isik_Alt_Value = 30;
int Isik = 70;
int Isik_Tavan_Value = 60;
int Toprak_Nem_Alt_Value = 30;
int Toprak_Nem = 25;
int Toprak_Nem_Tavan_Value = 60;
int NemlendiriciSu_Alt_Value = 30;
int NemlendiriciSu = 45;
int NemlemdiriciSu_Tavan_Value = 60;
//——————————————————————————
void setup() {
oled.begin(&Adafruit128x64, OLED_CS, OLED_DC, OLED_CLK, OLED_DATA);
oled.setFont(font5x7);

uint32_t m = micros();
oled.clear();
oled.set1X();
oled.setContrast(255);
oled.println(“IC SICAKLIK: “);
oled.println(“IC NEM: “);
oled.println(“IC ISIK: “);
oled.println(“TOPRAK NEM: “);
oled.println(“DIS SICAKLIK: “);
oled.println(“DIS NEM: “);
oled.println(“SU Sevi.-NEMLN: “);
oled.println(“SAAT: “);
}
//——————————————————————————
void loop() {}

 

Bağlantılar

  • D0 / CLK / SCK = 13
  • D1 / DATA / MOSI = 11
  • CS / SS = 10
  • DC / A0 = 9
  • RST / RESET = D8

mega

  • D0 / CLK / SCK = 52 / SARI / 39
  • D1 / DATA / MOSI = 51 / TURUNCU / 37
  • RST / RESET =49 / BEYAZ / 35
  • DC / A0 / MISO= 50 / YESIL /33
  • CS / SS = 53 / MAVI / 31

 

OLEDS withs Sensors

http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter

http://www.robotpark.com.tr/4-Kanalli-Cift-Yonlu-Lojik-Seviye-Donusturucu

OLED wiring

https://learn.adafruit.com/2-3-monochrome-128×32-oled-display-module/wiring-and-test

 

 

  • Connect Pin #1 to common power/data ground line (black wires)
  • Connect Pin #2 to the 3V power supply on your Arduino. (red wires)
  • Skip pin #3
  • Connect Pin #4 (DC & I2C Addr0) to ground (black wire) to set the I2C address to 0x3C. If this is tied to 3.3V, it will set the I2C address to 0x3D
  • Connect Pin #7 (SCL) to Arduino SCL (green wire)
  • Connect Pin #8 (SDA) to Arduino SDA (blue wire)
  • Connect Pin #9 (SDA2) to Pin #8 (small blue wire)
  • Skip pins #9-15
  • Connect Pin #16 (RST) to digital #9 by using a resistive divider as shown, two resistors from 1K to 10K both the same value can be used. Any pin can be used later

Leave a Reply

Your email address will not be published.