composants:i2c_oled_ssd1306

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
composants:i2c_oled_ssd1306 [2019/08/13 21:26] – [Usage] mhcomposants:i2c_oled_ssd1306 [2020/06/01 16:35] (current) – external edit 127.0.0.1
Line 18: Line 18:
 If you are connecting to SDA/SCL using I2C connect pin SDA to UNO A4 and SCL to UNO A5 (default pins, respectively 20 and 21 on a Mega) If you are connecting to SDA/SCL using I2C connect pin SDA to UNO A4 and SCL to UNO A5 (default pins, respectively 20 and 21 on a Mega)
  
 +
 +++++ Basic Arduino text example |
 +
 +<code c>
 +#include <SPI.h>
 +#include <Wire.h>
 +#include <Adafruit_GFX.h>
 +#include <Adafruit_SSD1306.h>
 +
 +#define SCREEN_WIDTH 128 // OLED display width, in pixels
 +#define SCREEN_HEIGHT 32 // OLED display height, in pixels
 +
 +// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
 +#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
 +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 +
 +void setup() {
 +  Serial.begin(9600);
 +
 +  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
 +  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
 +    Serial.println(F("SSD1306 allocation failed"));
 +    for(;;); // Don't proceed, loop forever
 +  }
 +}
 +
 +
 +void loop() {
 +  writeText();
 +}
 +
 +void writeText(void) {
 +  display.clearDisplay();
 +  display.setTextSize(1);             // Normal 1:1 pixel scale
 +  display.setTextColor(WHITE);        // Draw white text
 +  display.setCursor(0, 0);            // Start at top-left corner
 +  display.println(F("Hello, world!"));
 +  display.display();
 +}
 +
 +</code>
 +++++
 ===== Ressources ===== ===== Ressources =====
  
  • composants/i2c_oled_ssd1306.1565724417.txt.gz
  • Last modified: 2020/06/01 16:36
  • (external edit)