#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
// Declaration for SSD1306 display connected using I2C
#define OLED_RESET -1 // Reset pin
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup()
{
Serial.begin(115200);
// Initialize the OLED object
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
{
Serial.println(F("SSD1306 allocation failed"));
for (;;)
{
// Don't proceed, loop forever
}
}
// Clear the buffer.
display.clearDisplay(); // Clear the display
}
void loop()
{
// Scroll full screen
display.setCursor(0, 0); // Set the cursor position to the top-left corner
display.setTextSize(1); // Set the text size to 1
display.setTextColor(WHITE); // Set the text color to white
display.println("Full"); // Print "Full"
display.println("screen"); // Print "screen"
display.println("scrolling!"); // Print "scrolling!"
display.display(); // Update the display
// Start scrolling to the right
display.startscrollright(0x00, 0x07); // Start scrolling right with a start page of 0 and end page of 7
delay(2000); // Delay for 2 seconds
display.stopscroll(); // Stop scrolling
delay(1000); // Delay for 1 second
// Start scrolling to the left
display.startscrollleft(0x00, 0x07); // Start scrolling left with a start page of 0 and end page of 7
delay(2000); // Delay for 2 seconds
display.stopscroll(); // Stop scrolling
delay(1000); // Delay for 1 second
// Start diagonal scrolling to the right
display.startscrolldiagright(0x00, 0x07); // Start diagonal scrolling right with a start page of 0 and end page of 7
delay(2000); // Delay for 2 seconds
// Start diagonal scrolling to the left
display.startscrolldiagleft(0x00, 0x07); // Start diagonal scrolling left with a start page of 0 and end page of 7
delay(2000); // Delay for 2 seconds
display.stopscroll(); // Stop scrolling
display.clearDisplay(); // Clear the display buffer
}