Making a timer with a TM1637 Display

The timer runs SUPER fast.

#include <TM1637Display.h>
// Define the connections pins:
#define CLK 10
#define DIO 11
TM1637Display display = TM1637Display(CLK, DIO);

int oneButtonPin = 7;
int twoButtonPin = 8;
int threeButtonPin = 9;
int limitSWpin = 6;
int relay = 2;

int times[3] = {30, 60, 90};
int outputTime = 1000;

int one, two, three, lim;
int start = 0; int readyFlag = 0; int index = 0;
int selectedTime = 0;
unsigned long startMillis = 0;

void setup() {
pinMode(oneButtonPin, INPUT_PULLUP);
pinMode(twoButtonPin, INPUT_PULLUP);
pinMode(threeButtonPin, INPUT_PULLUP);
pinMode(limitSWpin, INPUT_PULLUP);
pinMode(relay, OUTPUT);

display.clear(); // Clear the display
display.setBrightness(7); // Set the brightness
delay(100);
}

void loop() {
readButtons();
if (!start ) {

display.showNumberDec(times[index]);
if (one)index = 0;
else if (two) index = 1;
else if (three) index = 2;

if (lim) {
start = 1;
selectedTime = times[index];
startMillis = millis();
}
}

if (start) {
while (selectedTime > 0 ) {
display.showNumberDec(selectedTime, 4);
if (startMillis - millis() >= 1000) {
selectedTime -= 1;
startMillis = millis();
}
}
digitalWrite(relay, HIGH);
delay(outputTime);
digitalWrite(relay, LOW);

start = 0;
}

}
void readButtons() {
one = !digitalRead(oneButtonPin);
two = !digitalRead(twoButtonPin);
three = !digitalRead(threeButtonPin);
lim = !digitalRead(limitSWpin);
//if (one || two || three || lim) delay(100);
}

Before posting anything please read:
https://forum.arduino.cc/index.php?topic=97455.0

And I'm not sure what your question was?

cole101:
Before posting anything please read:
Read this before posting a programming question ... - Programming Questions - Arduino Forum

And I'm not sure what your question was?

Sorry. The functions work correctly, however when it is triggered to start Via Pin 6, it isn't 30 seconds, its like 2 seconds. Basically the timing function isn't working at all. It does it's other intended purpose.
Basically its a timer, With 3 push buttons. When one button is pressed, it pre-sets that time, in seconds.
Once a limit switch is pressed, the count down starts. Once the time is up, it will Trigger pin 2, or a relay then start over.
The problem is that instead of taking the pre-set 30-60-90 second times, it takes literal seconds.

#include <TM1637Display.h>
// Define the connections pins:
#define CLK 10
#define DIO 11
TM1637Display display = TM1637Display(CLK, DIO);

int oneButtonPin = 7;
int twoButtonPin = 8;
int threeButtonPin = 9;
int limitSWpin = 6;
int relay = 2;

int times[3] = {30, 60, 90};
int outputTime = 1000;

int one, two, three, lim;
int start = 0; int readyFlag = 0; int index = 0;
int selectedTime = 0;
unsigned long startMillis = 0;

void setup() {
  pinMode(oneButtonPin, INPUT_PULLUP);
  pinMode(twoButtonPin, INPUT_PULLUP);
  pinMode(threeButtonPin, INPUT_PULLUP);
  pinMode(limitSWpin, INPUT_PULLUP);
  pinMode(relay, OUTPUT);

  display.clear(); // Clear the display
  display.setBrightness(7); // Set the brightness
  delay(100);
}

void loop() {
  readButtons();
  if (!start ) {

    display.showNumberDec(times[index]);
    if (one)index = 0;
    else if (two) index = 1;
    else if (three) index = 2;

    if (lim) {
      start = 1;
      selectedTime = times[index];
      startMillis = millis();
    }
  }

  if (start) {
    while (selectedTime > 0  ) {
      display.showNumberDec(selectedTime, 4);
      if (startMillis - millis() >= 1000) {
        selectedTime -= 1;
        startMillis = millis();
      }
    }
    digitalWrite(relay, HIGH);
    delay(outputTime);
    digitalWrite(relay, LOW);

    start = 0;
  }

}
void readButtons() {
  one = !digitalRead(oneButtonPin);
  two = !digitalRead(twoButtonPin);
  three = !digitalRead(threeButtonPin);
  lim = !digitalRead(limitSWpin);
  //if (one || two || three || lim) delay(100);
}

Did you check the internet for any results that may help your problem?