Thanks Oliver and Borland for your help and all memebers who have contributed to this forum. Finally, the two SPI OLED displays worked with a little tweaking to the code discussed in this thread. Below is the minimalistic code in case someone requires it:
/*
U8G2 TWO OLED SPI DISPLAY (MINIMALISTIC)
HARDWARE: ARDUINO UNO, SSD1306 SPI (7PIN) MODULES
Updated on 11/22/17
ARDUINO OLED INTERFACE:
1st OLED
13 - D0
11 - D1
10 - CS
9 - DC
8 - RES
2nd OLED
13 - D0
11 - D1
7 - CS
6 - DC
5 - RES
The Random number generator is merely to differentiate the two displays and ensure that they are working in HW mode.
PIN-13 and PIN-11 are common for both OLED modules. No seperate power lines are necessary.
*/
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
long randNumber1;
long randNumber2;
U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI OLED1(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI OLED2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5);
void setup() {
OLED1.begin();
OLED2.begin();
// put your setup code here, to run once:
}
void draw(void) {
OLED1.setFont(u8g_font_unifont);
OLED1.drawStr( 0, 22, "DISPLAY 1");
OLED1.setFont(u8g2_font_7x14B_mr);
OLED1.setCursor(1, 40);
OLED1.print(randNumber1);
}
void draw2(void) {
OLED2.setFont(u8g_font_unifont);
OLED2.drawStr( 0, 22, "DISPLAY 2");
OLED2.setFont(u8g2_font_7x14B_mr);
OLED2.setCursor(1, 40);
OLED2.print(randNumber2);
}
void loop(void) {
// put your main code here, to run repeatedly:
randNumber1 = random(0, 255);
randNumber2 = random(0, 255);
OLED1.firstPage();
do {
draw();
} while ( OLED1.nextPage() );
OLED2.firstPage();
do {
draw2();
} while ( OLED2.nextPage() );
delay(100);
}
Thanks again!