#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 4 // Reset pin # (or -1 if sharing reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup()
{
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) // I2C address = 0x3C
{
Serial.println("SSD1306 allocation failed");
while(1); //Don't proceed, loop forever
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 10);
display.print("Potensio");
display.display();
delay(2000);
}
void loop() {
display.clearDisplay();
//int sensorValue = analogRead(A0);
int sensorValue = random(20,30);
Serial.print("Analog Value =");
Serial.println(sensorValue);
//float voltage = (sensorValue / 1023.0) * 5.0;
//Serial.print("Voltage =");
//Serial.print(voltage);
//Serial.println(" V");
display.setCursor(5,30);
display.print(sensorValue);
//display.setCursor(5,45);
//display.print(voltage);
display.display();
delay(1000);
}