#include "U8glib.h"
#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int progress = 0;
void setup() {
myservo.attach(9);
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
}
void loop() {
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
u8g.firstPage();
do {
u8g.drawStr(25, 50, "Progress Bar");
u8g.drawFrame(0, 10, 128, 20);
u8g.drawBox(10, 15, val, 10);
} while ( u8g.nextPage() );
if (val <= 180) {
myservo.write(val);
} else if (val == 0) {
myservo.write(90);
}
}