how to define separate Wire for 2 SSD1306 OLED Display on Teensy 4.0

Status
Not open for further replies.

Aru

New member
Hello,

maybe simple question but....

this is my source code:
Code:
#include <Wire.h>                     //OLED
#include <Adafruit_SSD1306.h>         //OLED

//OLED
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

int showoff = 1;

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);                                          
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {                
    Serial.println(F("OLED F"));                                 
    for(;;);                                                      
  }     
  if(!display2.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {                
    Serial.println(F("OLED F"));                                 
    for(;;);                                                      
  }  

      display.clearDisplay();
      display.setTextSize(2);
      display.setCursor(1,0);
      display.setTextColor(SSD1306_WHITE);
      display.println(F("SCREEN 1"));
      display.display();

      display2.clearDisplay();
      display2.setTextSize(2);
      display2.setCursor(1,0);
      display2.setTextColor(SSD1306_WHITE);
      display2.println(F("SCREEN 2"));
      display2.display();


}
void loop() {

}

2 displays are already connected to 18/19 pins (SDA0/SCL0), now I want to connect 2 more displays and knowing fact that SSD1306 has only 2 addresses in selection I've figured out that I could get them connected to pins 17/16 (SDA1/SCL1)... but as I saw that need to be declared in setup (Wire.begin()). I'm fresh at this and little confused how to do it.

Could someone help? :)
 
so it will work if I simply define this display as follows?

Code:
Adafruit_SSD1306 display3(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);
Adafruit_SSD1306 display4(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);
 
Status
Not open for further replies.
Back
Top