OLED Farbdisplay mit 65000 Farben über SPI mit dem Arduino UNO betreiben
In dieser Anleitung erfahren Sie, wie Sie eine farb-OLED mit 65000 farben über SPI mit dem Arduino ansteuern können.

Das OLED Display hat dabei die folgenden Eigenschaften:
- Auflösung: 96×64 pixel
- Farben: 65000
- Treiberchip: ssd1331
Pinbelegung:
- GND
- VCC: 2,8V – 5,5V
- D0:CLK clock
- D1: MOSI data
- RST: reset
- CS: chip-select signal
Die Verschaltung ist dabei wie wie folgt vorzunehmen:


Anschließend benötigen Sie die Bibliothek “Ucglib“. Eine Installationsanleitung von Bibliotheken Innerhalb der Arduino IDE finden Sie hier.
#include <SPI.h>
#include "Ucglib.h"
/*
Hardware SPI Pins:
Arduino Uno sclk=13, data=11
Arduino Due sclk=76, data=75
Arduino Mega sclk=52, data=51
*/
Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8);
void color_test(void)
{
ucg_int_t mx;
uint16_t c, x;
mx = ucg.getWidth() / 2;
//my = ucg.getHeight() / 2;
ucg.setColor(0, 0, 0, 0);
ucg.drawBox(0, 0, ucg.getWidth(), ucg.getHeight());
ucg.setColor(255, 255, 255);
ucg.setPrintPos(2,18);
ucg.setPrintDir(0);
ucg.print("42project");
ucg.setColor(0, 127, 127, 127);
ucg.drawBox(0, 20, 16*4+4, 5*8+4);
for( c = 0, x = 2; c <= 255; c+=17, x+=4 )
{
ucg.setColor(0, c, c, c);
ucg.drawBox(x, 22, 4, 8);
ucg.setColor(0, c, 0, 0);
ucg.drawBox(x, 22+8, 4, 8);
ucg.setColor(0, 0, c, 0);
ucg.drawBox(x, 22+2*8, 4, 8);
ucg.setColor(0, 0, 0, c);
ucg.drawBox(x, 22+3*8, 4, 8);
ucg.setColor(0, c, 255-c, 0);
ucg.drawBox(x, 22+4*8, 4, 8);
}
}
void setup(void)
{
delay(1000);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.setFont(ucg_font_ncenR14_hr);
ucg.clearScreen();
color_test();
}
void loop(void)
{
}
Noch keine Kommentare.