// #include <SPI.h>
// #include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display (SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // create an object/instance of Adafruit_SSD1406
void setup() {
Serial.begin(115200); // start Serial Monitor
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // OLED address
display.clearDisplay(); // clear the OLED buffer
display.display(); // call this to display OLED buffer
display.setTextSize(1); // set text size (optional)
display.setTextColor(WHITE); // set text color
display.setCursor(0, 0); // set cursor location
display.println("Hello, World!"); // print data to OLED buffer
display.print("\n\nNumber overwritten \nin black");
display.display(); // display the OLED buffer
}
void loop() {
int i;
for (i = 0; i < 9; i++)
{
display.setTextColor(WHITE); // draw with white
display.setCursor(50, 32);
display.print(i);
display.display();
delay(1000);
display.setTextColor(BLACK); // erase with black
display.setCursor(50, 32);
display.print(i);
display.display();
}
}
/*
More OLED functions:
display.clearDisplay() // all pixels off
display.setTextColor(WHITE); // text color
display.setTextSize(n) // set the font size 1 to 8
display.setCursor(x,y) // set the coordinates to start writing text
display.print(“message”) // print the characters at location x,y
display.drawPixel(x,y, WHITE) // plot a pixel in the x,y coordinates
display.drawLine(x1, y1, x2, y2, WHITE) // draw line from x1,y1 to x2,y2, WHITE
display.drawRect(x, y, width, height, WHITE) // draw a rectangle origin at x,y
display.drawTriangle(x1, y1, x2, y2, x3, y3, color)
display.drawCircle(x, y, radius, color
display.display() // MUST call this method for the changes to take effect
Convert image to bitmap for OLED
https://sourceforge.net/projects/lcd-image-converter/files/
*/