Display OLED 0.96" I2C IIC Albastru

Cod 00090
19,64RON
În stoc
1
Detalii produs

Display OLED 0.96 inch culoare Albastru, compatibil Arduino si alte placi de dezvoltare. Ideal pentru proiecte de mici dimensiuni datorita interfetei de comunicare I2C si IIC.

Acest display nu necesita de retroiluminare (aceasta fiind data de pixeli)

Specificatii:

Rezoluitie mare: 128X64

Unghi vizual: >160 °

Consum ultra redus: 0.08W

Tensiune alimentare: DC 3V-5V

Temperatura functionare: -30 ~70 degree

Dimensiuni mm: 29 x 27.5 x 4.3

Dimensiuni display activ mm: 26.5 x 14.8

Suport: IIC, I2C

Compatibil la nivel I/O direct cu microcontrollere pe 3.3V si 5V (compatibil direct, fara convertoare)

Chip: SSD1306


Comunicarea IIC ocupa un numar minim de pini.

Descriere pini:

GND: power ground

VCC: 3.3V sau 5V sursa alimentare

SCL: IIC clock line

SDA: IIC data line


Conectare:

GND --------> GND

VCC --------> 3.3V

D1 --------> D11 (MOSI) (nu se schimba)

D0 --------> D13 (SCK) (nu se modifică)

DC --------> D8 (poate fi orice pin digital)

RES --------> D9 (poate fi orice PIN digital)


Exemplu Cod:

#include // Include Wire if you're using I2C

#include // Include SPI if you're using SPI
#include // Include the HT_SSD1306 library

//////////////////////////
// SSD1306 Definition //
//////////////////////////
#define PIN_RESET 9 // Connect RST to pin 9 (SPI & I2C)
#define PIN_DC 8 // Connect DC to pin 8 (SPI only)
#define PIN_CS 10 // Connect CS to pin 10 (SPI only)
#define DC_JUMPER 1 // DC jumper setting(I2C only)

//////////////////////////////////
// SSD1306 Object Declaration //
//////////////////////////////////
SSD1306 oled(PIN_RESET, PIN_DC, PIN_CS); // SPI Example
//SSD1306 oled(PIN_RESET, DC_JUMPER); // I2C Example

// Use these variables to set the initial time
int hours = 15;
int minutes = 22;
int seconds = 30;

// How fast do you want the clock to spin? Set this to 1 for fun.
// Set this to 1000 to get _about_ 1 second timing.
const int CLOCK_SPEED = 1000;

// Global variables to help draw the clock face:
const int MIDDLE_Y = oled.getLCDHeight() / 2;
const int MIDDLE_X = oled.getLCDWidth() / 2;

int CLOCK_RADIUS;
int POS_12_X, POS_12_Y;
int POS_3_X, POS_3_Y;
int POS_6_X, POS_6_Y;
int POS_9_X, POS_9_Y;
int S_LENGTH;
int M_LENGTH;
int H_LENGTH;

unsigned long lastDraw = 0;

void initClockVariables()
{
// Calculate constants for clock face component positions:
oled.setFontType(0);
CLOCK_RADIUS = min(MIDDLE_X, MIDDLE_Y) - 1;
POS_12_X = MIDDLE_X - oled.getFontWidth();
POS_12_Y = MIDDLE_Y - CLOCK_RADIUS + 2;
POS_3_X = MIDDLE_X + CLOCK_RADIUS - oled.getFontWidth() - 1;
POS_3_Y = MIDDLE_Y - oled.getFontHeight()/2;
POS_6_X = MIDDLE_X - oled.getFontWidth()/2;
POS_6_Y = MIDDLE_Y + CLOCK_RADIUS - oled.getFontHeight() - 1;
POS_9_X = MIDDLE_X - CLOCK_RADIUS + oled.getFontWidth() - 2;
POS_9_Y = MIDDLE_Y - oled.getFontHeight()/2;

// Calculate clock arm lengths
S_LENGTH = CLOCK_RADIUS - 2;
M_LENGTH = S_LENGTH * 0.7;
H_LENGTH = S_LENGTH * 0.5;
}

void setup()
{
oled.begin(); // Initialize the OLED
oled.clear(PAGE); // Clear the display's internal memory
oled.clear(ALL); // Clear the library's display buffer
oled.logo();
oled.display(); // Display what's in the buffer (splashscreen)
delay(2000);
initClockVariables();

oled.clear(ALL);
drawFace();
drawArms(hours, minutes, seconds);
oled.display(); // display the memory buffer drawn
}

void loop()
{

// Check if we need to update seconds, minutes, hours:
if (lastDraw + CLOCK_SPEED < millis())
{
lastDraw = millis();
// Add a second, update minutes/hours if necessary:
updateTime();

// Draw the clock:
oled.clear(PAGE); // Clear the buffer
drawFace(); // Draw the face to the buffer
drawArms(hours, minutes, seconds); // Draw arms to the buffer
oled.display(); // Draw the memory buffer
}
}

// Simple function to increment seconds and then increment minutes
// and hours if necessary.
void updateTime()
{
seconds++; // Increment seconds
if (seconds >= 60) // If seconds overflows (>=60)
{
seconds = 0; // Set seconds back to 0
minutes++; // Increment minutes
if (minutes >= 60) // If minutes overflows (>=60)
{
minutes = 0; // Set minutes back to 0
hours++; // Increment hours
if (hours >= 12) // If hours overflows (>=12)
{
hours = 0; // Set hours back to 0
}
}
}
}

// Draw the clock's three arms: seconds, minutes, hours.
void drawArms(int h, int m, int s)
{
double midHours; // this will be used to slightly adjust the hour hand
static int hx, hy, mx, my, sx, sy;

// Adjust time to shift display 90 degrees ccw
// this will turn the clock the same direction as text:
h -= 3;
m -= 15;
s -= 15;
if (h <= 0)
h += 12;
if (m < 0)
m += 60;
if (s < 0)
s += 60;

// Calculate and draw new lines:
s = map(s, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
sx = S_LENGTH * cos(PI * ((float)s) / 180); // woo trig!
sy = S_LENGTH * sin(PI * ((float)s) / 180); // woo trig!
// draw the second hand:
oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + sx, MIDDLE_Y + sy);

m = map(m, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
mx = M_LENGTH * cos(PI * ((float)m) / 180); // woo trig!
my = M_LENGTH * sin(PI * ((float)m) / 180); // woo trig!
// draw the minute hand
oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + mx, MIDDLE_Y + my);

midHours = minutes/12; // midHours is used to set the hours hand to middling levels between whole hours
h *= 5; // Get hours and midhours to the same scale
h += midHours; // add hours and midhours
h = map(h, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
hx = H_LENGTH * cos(PI * ((float)h) / 180); // woo trig!
hy = H_LENGTH * sin(PI * ((float)h) / 180); // woo trig!
// draw the hour hand:
oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + hx, MIDDLE_Y + hy);
}

// Draw an analog clock face
void drawFace()
{
// Draw the clock border
oled.circle(MIDDLE_X, MIDDLE_Y, CLOCK_RADIUS);

// Draw the clock numbers
oled.setFontType(0); // set font type 0, please see declaration in SFE_MicroOLED.cpp
oled.setCursor(POS_12_X, POS_12_Y); // points cursor to x=27 y=0
oled.print(12);
oled.setCursor(POS_6_X, POS_6_Y);
oled.print(6);
oled.setCursor(POS_9_X, POS_9_Y);
oled.print(9);
oled.setCursor(POS_3_X, POS_3_Y);
oled.print(3);
}

CS -------- D10 (poate fi orice PIN digital)

Salvează acest produs pentru mai târziu