#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 an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// put your setup code here, to run once:
// put your setup code here, to run once:
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
Serial.begin(9600);
// put your main code here, to run repeatedly:
display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
}
void loop() {
updatedisplay();
delay(2000);
updatedisplay1();
delay(2000);
}
void updatedisplay(void) {
display.clearDisplay();
display.setCursor(0, 0);
display.println ("CW");
display.print ("12345");
display.println (" RPM");
display.print ("54321");
display.println (" RPS");
display.display();
}
void updatedisplay1(void) {
display.clearDisplay();
display.setCursor(0, 0);
display.println ("CCW");
display.print ("54321");
display.println (" RPS");
display.display();
}