#include "U8glib.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 buttonStateUp = 0;
int buttonStateDown = 0;
const int buttonUp = 2;
const int buttonDown = 3;
void setup() {
Serial.begin(115200);
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
pinMode(buttonUp, INPUT);
pinMode(buttonDown, INPUT);
}
void loop() {
buttonStateUp = digitalRead(buttonUp);
buttonStateDown = digitalRead(buttonDown);
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 (buttonStateUp)
{
progress++;
}
if (buttonStateDown)
{
progress--;
}
if (progress > 100)
{
progress = 100;
}
else if (progress < 0)
{
progress = 0;
}
// if (progress < 108 && progress > -1) {
// if(buttonStateUp == HIGH)
// progress++;
// if(buttonStateDown == HIGH)
// progress--;
// } else {
// progress = 0;
// }
}