#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const int adc = 36;
int current = 0;
int previous = 0;
int check = 0;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
}
void loop() {
if(check < SCREEN_WIDTH){
check = check + 1;
previous = current;
current = round(analogRead(adc) * SCREEN_HEIGHT / 4096);
display.drawLine(check - 1, SCREEN_HEIGHT - previous, check, SCREEN_HEIGHT - current, WHITE);
display.display();
} else {
check = 0;
current = 0;
display.clearDisplay();
}
}