Roombaduino – part 25 – Follow-up

A long while back, I demonstrated how to multiplex 2 OLED i2c displays which have the same i2c address. The video is here:


I was asked a couple of questions in the comments about how it worked.

Firstly, when the data has been sent to the display, does it stay there? That is do you need to refresh it?

Secondly, are both OLEDs able to share the SCL (clock) line?

I’ll answer in reverse order. Yes and No. 🙂

As I explained in the video, all the devices you want to multiplex share the clock line. The SDA (data) line is what is multiplexed.

For the actual data being sent, there is no need to refresh it. I don’t have the exact details on exactly how that information is stored ( who reads datasheets? ) but the code I used for the video demonstration is below and I don’t refresh anything.


#include <Wire.h>
#include <OzOLED.h>

#define MUX1 6
#define MUX2 7
#define MUX3 8

#define NUM_SCREENS 2
int screen = 1;
int i = 1 ;

void setDisplay( byte displaynum )
 digitalWrite( MUX1, (displaynum & 0x01 ? HIGH : LOW) );
 digitalWrite( MUX2, (displaynum & 0x02 ? HIGH : LOW) );
 digitalWrite( MUX3, (displaynum & 0x04 ? HIGH : LOW) );

void setup() {

 pinMode( MUX1, OUTPUT );
 pinMode( MUX2, OUTPUT );
 pinMode( MUX3, OUTPUT );

 for( int s = 1 ; s <= NUM_SCREENS; s++ )
 setDisplay( s );

 // Rotated 180 degrees
 OzOled.sendCommand( 0xC8 );
 OzOled.sendCommand( 0xA1 );
 OzOled.sendCommand( 0x0DA );
 OzOled.sendCommand( 0x012 );
 OzOled.setBrightness( 0xFF );

 OzOled.sendCommand( 0x8d );
 OzOled.sendCommand( 0x14 );


void loop()

 setDisplay( screen );


 OzOled.printNumber( (long)i );
 if( screen > NUM_SCREENS ) screen = 1;

Leave a Reply

Your email address will not be published. Required fields are marked *