Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| composants:i2c_oled_ssd1306 [2019/01/06 20:10] – mh | composants:i2c_oled_ssd1306 [2025/06/02 21:23] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== I2C OLED 0.91 inch Screen ====== | ====== I2C OLED 0.91 inch Screen ====== | ||
| - | ===== Résumé ===== | + | Exists in various format (128x32, 128x64) |
| - | Un petit écran qui utilise le driver SSD1306. S' | + | {{composants: |
| - | ===== Utilisation | + | ===== Specifications |
| - | Dans Arduino il y a plusieurs bibliothèques qui permettent de s' | + | *5V ready |
| + | *Can use I2C (two wires) or SPI communication | ||
| - | Il faut d' | + | ===== Usage ===== |
| - | Le module 128x32 utilise l' | + | You can use **Adafruit SSD1306**. |
| - | ++++On peut utiliser | + | The 128x32 uses address 0x3C |
| + | |||
| + | 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> | <code c> | ||
| + | #include < | ||
| #include < | #include < | ||
| - | + | #include < | |
| - | void setup() | + | #include < |
| - | { | + | |
| - | | + | #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 | ||
| + | Adafruit_SSD1306 display(SCREEN_WIDTH, | ||
| + | |||
| + | void setup() { | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| - | while (!Serial); | + | |
| - | Serial.println(" | + | |
| - | } | + | |
| - | + | Serial.println(F("SSD1306 allocation failed")); | |
| - | void loop() | + | for(;;); // Don't proceed, loop forever |
| - | { | + | |
| - | | + | |
| - | int nDevices; | + | |
| - | + | ||
| - | Serial.println(" | + | |
| - | + | ||
| - | nDevices = 0; | + | |
| - | for(address = 1; address < 127; address++ | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | // a device did acknowledge to the address. | + | |
| - | Wire.beginTransmission(address); | + | |
| - | error = Wire.endTransmission(); | + | |
| - | + | ||
| - | if (error == 0) | + | |
| - | { | + | |
| - | | + | |
| - | if (address< | + | |
| - | Serial.print("0"); | + | |
| - | Serial.print(address, | + | |
| - | | + | |
| - | + | ||
| - | nDevices++; | + | |
| - | } | + | |
| - | else if (error==4) | + | |
| - | { | + | |
| - | Serial.print(" | + | |
| - | if (address< | + | |
| - | Serial.print(" | + | |
| - | Serial.println(address,HEX); | + | |
| - | } | + | |
| } | } | ||
| - | if (nDevices == 0) | ||
| - | Serial.println(" | ||
| - | else | ||
| - | Serial.println(" | ||
| - | |||
| - | delay(100); | ||
| } | } | ||
| - | </ | ||
| - | ++++ | ||
| + | void loop() { | ||
| + | writeText(); | ||
| + | } | ||
| + | |||
| + | void writeText(void) { | ||
| + | display.clearDisplay(); | ||
| + | display.setTextSize(1); | ||
| + | display.setTextColor(WHITE); | ||
| + | display.setCursor(0, | ||
| + | display.println(F(" | ||
| + | display.display(); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ++++ | ||
| ===== Ressources ===== | ===== Ressources ===== | ||
| - | Acheté de la marque | + | Bought from MakerHawk |
| - | *[[https:// | + | *[[https:// |