#include "U8glib.h"
#include "Servo.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int progress = 0;
int maxValue = 108;
int potentiometerPin = A0;
int servoPin = 9;
Servo servo;
void setup() {
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
servo.attach(servoPin);
}
void loop() {
int potentiometerValue = analogRead(potentiometerPin);
progress = map(potentiometerValue, 0, 1023, 0, maxValue);
u8g.firstPage();
do {
u8g.drawStr(25, 50, "Progress Bar");
u8g.drawFrame(0, 10, 128, 20);
u8g.drawBox(10, 15, progress, 10);
} while (u8g.nextPage());
if (progress >= maxValue) {
// Move the servo motor when the progress bar reaches its maximum value
servo.write(90); // Adjust the angle as per your requirement
} else {
servo.write(0); // Set the servo to its initial position
}
}