Skip to content

Commit 500bd8a

Browse files
authored
Merge pull request adafruit#199 from flywire/master
#define SCREEN_ADDRESS instead of hard-coded value
2 parents 56a1c94 + 018e49e commit 500bd8a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

examples/ssd1306_128x32_i2c/ssd1306_128x32_i2c.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
3333
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
3434
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
35+
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
3536
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
3637

3738
#define NUMFLAKES 10 // Number of snowflakes in the animation example
@@ -60,7 +61,7 @@ void setup() {
6061
Serial.begin(9600);
6162

6263
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
63-
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
64+
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
6465
Serial.println(F("SSD1306 allocation failed"));
6566
for(;;); // Don't proceed, loop forever
6667
}

examples/ssd1306_128x64_i2c/ssd1306_128x64_i2c.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
2828

2929
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
30+
// The pins for I2C are defined by the Wire-library.
31+
// On an arduino UNO: A4(SDA), A5(SCL)
32+
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
33+
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
3034
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
35+
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
3136
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
3237

3338
#define NUMFLAKES 10 // Number of snowflakes in the animation example
@@ -56,7 +61,7 @@ void setup() {
5661
Serial.begin(9600);
5762

5863
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
59-
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) { // Address 0x3D for 128x64
64+
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
6065
Serial.println(F("SSD1306 allocation failed"));
6166
for(;;); // Don't proceed, loop forever
6267
}

0 commit comments

Comments
 (0)