/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com
*********/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
int pot = A0;
#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)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
static const unsigned char PROGMEM image_RFIDBigChip_37x36_bits[] = {0x60, 0x00, 0x00, 0x00, 0x00, 0x67, 0xff, 0xff, 0xff, 0xe0, 0x48, 0x00, 0x00, 0x00, 0x10, 0x93, 0xff, 0xff, 0xff, 0xc8, 0xa4, 0x00, 0x00, 0x00, 0x28, 0xa8, 0x03, 0x57, 0xff, 0x28, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x00, 0x00, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x03, 0xfe, 0x00, 0xa8, 0xaa, 0x04, 0x01, 0x02, 0xa8, 0xa9, 0x09, 0xec, 0x84, 0xa8, 0xa8, 0xba, 0x0c, 0xe8, 0xa8, 0xaa, 0x0a, 0x00, 0x82, 0xa8, 0xa9, 0xb8, 0x02, 0xec, 0xa8, 0xa8, 0x0a, 0x02, 0x80, 0xa8, 0xa9, 0xb8, 0x02, 0xec, 0xa8, 0xaa, 0x0a, 0x02, 0x82, 0xa8, 0xa8, 0xba, 0x02, 0xe8, 0xa8, 0xa9, 0x09, 0x7c, 0x84, 0xa8, 0xaa, 0x04, 0x01, 0x02, 0xa8, 0xa8, 0x03, 0xfe, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x00, 0x00, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x01, 0x54, 0x00, 0xa8, 0xa8, 0x03, 0x56, 0x00, 0xa8, 0xa8, 0x00, 0x00, 0x00, 0xa8, 0xa7, 0xff, 0xff, 0xff, 0x28, 0xa0, 0x00, 0x00, 0x00, 0x28, 0x9f, 0xff, 0xff, 0xff, 0xc8, 0x40, 0x00, 0x00, 0x00, 0x10, 0x3f, 0xff, 0xff, 0xff, 0xe0};
static const unsigned char PROGMEM image_Medium_chip_22x21_bits[] = {0x3f, 0xff, 0xf0, 0x40, 0x00, 0x08, 0x9f, 0xff, 0xe4, 0xa1, 0x4a, 0x14, 0xa3, 0xff, 0x14, 0xa4, 0x00, 0x94, 0xa9, 0xe6, 0x54, 0xba, 0x06, 0x74, 0xaa, 0x00, 0x54, 0xb8, 0x01, 0x74, 0xaa, 0x01, 0x54, 0xb8, 0x01, 0x74, 0xaa, 0x01, 0x54, 0xba, 0x01, 0x74, 0xa9, 0xbe, 0x54, 0xa4, 0x00, 0x94, 0xa3, 0xff, 0x14, 0xa1, 0x4a, 0x14, 0x9f, 0xff, 0xe4, 0x40, 0x00, 0x08, 0x3f, 0xff, 0xf0};
void setup() {
Serial.begin(115200);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
delay(100);
display.clearDisplay();
for (int x = 3; x <= 128; x++) {
display.drawBitmap(x, 23, image_Medium_chip_22x21_bits, 22, 21, 1);
display.setTextColor(1);
display.setTextSize(2);
display.setCursor(9, 5);
//display.setTextWrap(false);
display.print("Solutions");
display.display();
display.clearDisplay();
}
delay(100);
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(2);
display.setCursor(9, 5);
display.setTextWrap(false);
display.print("Solutions");
display.setCursor(22, 28);
display.setTextWrap(false);
display.print("Welcome");
display.display();
delay(2000);
}
void loop() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
int val = analogRead(pot);
int i = map(val, 0, 1023, 13, 118);
int j = map(i, 13, 118, 63, -63);
display.drawCircle(65, 73, 60, 1);
display.drawCircle(65, 79, 50, 1);
display.fillCircle(65, 66, 9, 1);
display.drawCircle(65, 66, 11, 1);
if (abs(j) < 22) {
j = 22;
}
display.drawLine(66, 63, i, abs(j), 1);
display.display();
delay(20);
display.clearDisplay();
}