Using mills and the for statement

I am having lots of trouble figuring out the right way to add 1 to one of my variables after a second.
Its more like

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup(){
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(10);
display.clearDisplay();

}
void loop(){
unsigned long mills = millis();
int second = mills/1000;
int seconds = 1;
for(int i = 0; i<=60; i++){
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("The current Time is: ");
display.setCursor(0,10);
display.println(seconds);
display.display();
display.clearDisplay();
}

}

What i am trying to do is add (+1) every second to my (Seconds variable) using the for statement but the thing is that it adds (+1) faster than a second when i want it to add (+1) every second .

please help this noob! :confused:

paolo_cooper:
I am having lots of trouble figuring out the right way to add 1 to one of my variables after a second.
Its more like

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup(){
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(10);
display.clearDisplay();

}
void loop(){
unsigned long mills = millis();
int second = mills/1000;
int seconds = 1;
for(int i = 0; i<=60; i++){
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("The current Time is: ");
display.setCursor(0,10);
display.println(seconds);
display.display();
display.clearDisplay();
}

}

What i am trying to do is add (+1) every second to my (Seconds variable) using the for statement but the thing is that it adds (+1) faster than a second when i want it to add (+1) every second .

please help this noob! :confused:

But then you set seconds to 1.

int seconds = 1;

Why?

paul

Have you read Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.

unsigned long currentMillis;
unsigned long periodStartMillis;
unsigned long period = 1000;
int seconds;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  currentMillis = millis();
  if (currentMillis - periodStartMillis >= 1000)
  {
    seconds++;
    Serial.print(seconds);
    Serial.println(" seconds");
    periodStartMillis = currentMillis;
  }
}