#include <Wire.h>
#include <U8g2lib.h>

#define RESET_BUTTON 5

U8G2_SSD1309_128X64_NONAME0_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);
int counter = 0;
void setup() {
  Serial.begin(9600);
  oled.begin();
  oled.setFont(u8g2_font_7x14_mf);
}

void loop() {
  static long startTime = 0;
  long currentTime;
  buttonPress();
  // Get current time
    currentTime = millis();
  // Checks 1 second passed
     if ((currentTime - startTime) > 1000) {
      increase();
      startTime = currentTime;    
      //Serial.println(counter);      
    }
  oled.firstPage();
  do {
    oled.drawStr(10,20,"COUNTER: ");
    oled.setCursor(80,20);
    oled.print(counter); 
  } while ( oled.nextPage() );

}
void increase() {
  counter++;
  delay(1000);
}
void buttonPress(){
  //button press
  byte buttonState = digitalRead(RESET_BUTTON);
  if (buttonState == LOW){
    Serial.println("button pressed");
    } else {Serial.println("button not pressed");
  };
  delay(1);
}