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/08/13 20:32] – mh | composants:i2c_oled_ssd1306 [2025/06/02 21:23] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| *5V ready | *5V ready | ||
| + | *Can use I2C (two wires) or SPI communication | ||
| ===== Usage ===== | ===== Usage ===== | ||
| Line 15: | Line 16: | ||
| The 128x32 uses address 0x3C | 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> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #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); | ||
| + | |||
| + | // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally | ||
| + | if(!display.begin(SSD1306_SWITCHCAPVCC, | ||
| + | Serial.println(F(" | ||
| + | for(;;); // Don't proceed, loop forever | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | void loop() { | ||
| + | writeText(); | ||
| + | } | ||
| + | |||
| + | void writeText(void) { | ||
| + | display.clearDisplay(); | ||
| + | display.setTextSize(1); | ||
| + | display.setTextColor(WHITE); | ||
| + | display.setCursor(0, | ||
| + | display.println(F(" | ||
| + | display.display(); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ++++ | ||
| ===== Ressources ===== | ===== Ressources ===== | ||