I recent purchased an OLED from eBay, which I managed to get working with an Arduino Uno. Note, odd PCB labels which are i2c but works from SPI.
I now want to use a micro for a mini project and cannot get the display working, i think the GPIO references are wrong but cannot understand what is going on. Currently I have the following connections
Micro 3.3 -> display VCC
Micro GND -> display Gnd
Micro PB2 (MISO) -> display SDA
Micro PB1 (SCK) -> display SCL
Micro PD6 -> display RES
Micro PB7 -> display DC
This is the code I am using, which is based off the Adafruit standard lib
#include
#include
#include
#include
// If using software SPI (the default case):
/*
#define OLED_MOSI 9 // display sda
#define OLED_CLK 10 // display scl
#define OLED_DC 11 // - display dc
#define OLED_CS 12
#define OLED_RESET 13 // display res
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
*/
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(3, 2); // RX | TX
/* Uncomment this block to use hardware SPI */
#define OLED_DC 12
#define OLED_CS 7
#define OLED_RESET 10
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
String inputString = ""; // a string to hold incoming data
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("Script started");
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC);
// init done
Serial.println("Display cleared");
display.clearDisplay();
}
void loop()
{
display.clearDisplay();
inputString = "Test Test Test";
display.setTextSize(1.5);
display.setTextColor(WHITE);
display.setCursor(30,10);
display.println(inputString);
display.drawLine(0, 0, 0, 31, WHITE);
display.drawLine(0, 0, 127,0, WHITE);
display.drawLine(127, 0, 127, 31, WHITE);
display.drawLine(0, 31, 127, 31, WHITE);
display.display();
delay(200);
Serial.println("Loop finished");
}
Could any one help if there is a problem or am I doing something silly