Skip to content

Instantly share code, notes, and snippets.

@deladriere
Created December 7, 2017 06:29
Show Gist options
  • Save deladriere/9c5669f359ae4551fb08ffa6b980d181 to your computer and use it in GitHub Desktop.
Save deladriere/9c5669f359ae4551fb08ffa6b980d181 to your computer and use it in GitHub Desktop.
Adafruit SSD1306 I2C text speed test
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
long I2C_clock=250000;
long pot;
unsigned long thisMicros = 0;
unsigned long lastMicros = 0;
void setup() {
// Serial.begin(9600);
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
}
void loop()
{
pot=analogRead(5);// pot on A5 to play with the I2C clock
I2C_clock=map(pot,1023,0,100L,4000L);
I2C_clock=I2C_clock*1000L;
Wire.setClock(I2C_clock);
thisMicros = micros();
display.clearDisplay();
display.setCursor(0,0);
display.print(thisMicros - lastMicros);
display.setCursor(0,20);
display.print(I2C_clock);
display.setCursor(0,40);
display.print(pot);
display.display();
lastMicros = thisMicros;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment