#include <Adafruit_SSD1306.h>
#define screen_width 128
#define screen_height 64
int pm = A0;
Adafruit_SSD1306 display(screen_width,screen_height);
String text;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC,0X3C);
text = "abraham";
}
void loop() {
// put your main code here, to run repeatedly:
display.clearDisplay();
// display.setTextSize(1);
// display.setTextColor(1);
// display.setCursor(30,20);
// display.print(text);
int p_val = analogRead(pm);
int p_map = map(p_val,0,1023,0,100);
// Serial.print("Reading: ");
// Serial.println(p_map);
display.setTextSize(1);
display.setTextColor(1);
display.setCursor(30,1);
display.print(p_map);
display.print("%");
// Draw the battery outline
display.drawRect(34, 32, 60, 20, SSD1306_WHITE); // Battery body
display.drawRect(94, 36, 4, 12, SSD1306_WHITE); // Battery terminal
// Draw the battery level
int chargeWidth = map(p_map, 0, 100, 0, 58); // Map the charge percentage to the width of the battery
display.fillRect(36, 34, chargeWidth-2, 16, SSD1306_WHITE);
// Display the content on the screen
display.display();
}