HElP, Counter to 9 with a shift register without delay not working

hello everybody, thank you in advance for your reply and help,
I make counter from 0 to 9 without delay but i can not make it , can me some one remodel code to see how it would work out with the function of Millis.

const int latchPin = 2;
const int dataPin = 3;
const int clockPin = 4;

int ledState1 = LOW;
int ledState2 = LOW;
int ledState3 = LOW;

unsigned long previousMillis = 0;

const long interval = 1000;

void setup() {

pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}

void loop() {

unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {

previousMillis = currentMillis;

if (ledState1 == LOW) {
ledState1 = HIGH;
} else {
ledState1 = LOW;
}

digitalWrite(latchPin, ledState1);

if (ledState2 == LOW) {
ledState2 = HIGH;
} else {
ledState2 = LOW;
}

digitalWrite(dataPin, ledState2);

if (ledState3 == LOW) {
ledState3 = HIGH;
} else {
ledState3 = LOW;
}

digitalWrite(clockPin, ledState3);

//0
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 64);
digitalWrite(latchPin, HIGH);
//1
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 121);
digitalWrite(latchPin, HIGH);

//2
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 36);
digitalWrite(latchPin, HIGH);

//3
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 48);
digitalWrite(latchPin, HIGH);

//4
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 25);
digitalWrite(latchPin, HIGH);

//5
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 18);
digitalWrite(latchPin, HIGH);

//6
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 2);
digitalWrite(latchPin, HIGH);

//7
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 120);
digitalWrite(latchPin, HIGH);

//8
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);

//9
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 24);
digitalWrite(latchPin, HIGH);

}
}

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What is your code doing?

Thanks.. Tom... :slight_smile:

Please don't post many times for the same issue. You are wasting everyone's time. That is very poor practice

Why do you use ledState to toggle data, latch and clockpin? I am pretty sure it is a bad idea to manipulate data and clockpin. Is it left overs from copied code?

It looks like you have a 7 segment display, but you send every digit in sequence instead of 1 digit every second. You need a counter to keep track of which number you have sent.
A good way to do that is to put your segment encoded numbers in an array. When counter is 5 you send value 5 from your array.