Looking for Timer Library simple as delay();

I tried millis() to delay but it makes the code much complex.I like delay() but delay()creates response problems for buttons and potentiometer.

Is there any library that doesn't create response problems and simple as delay()?

Thanks

I tried millis() to delay but it makes the code much complex.

:o

Would you show us what you did when you used millis() ?

Is this not simple enough?

if (millis()-startTime >= interval) 
{
    startTime=millis();
   // Do something
}

I need small intervals.I have to use if millis() everytime so it makes it more complex.I am trying to build a metronome.I am just looking for delay(); with no responsive problems.Is there any library?

Would you show us what you did when you used millis() ?

Without knowing more maybe this will work: http://playground.arduino.cc/Code/Scheduler

thereyouare:
I need small intervals.I have to use if millis() everytime so it makes it more complex.I am trying to build a metronome.I am just looking for delay(); with no responsive problems.Is there any library?

Even if you consider that the code using millis() looks complex you must keep in mind that the only way a library can make it LOOK simpler is actually by adding a lot more code. The underlying process will be the same.

This has two potential impacts. The one that shows its head most often here is that the library doesn't do exactly what the user wants, or the user doesn't know how to use it and there is little or no documentation. The net result is that the user spends his time trying to learn/fix the library rather than working on his own project.

The other is that longer code will inevitably take longer to work which is not good news if you are concerned about short time intervals.

...R

Is there any library that doesn’t create response problems and simple as delay()?

No.

I have tried to simplify the code as much as possible.

int led1 = 4;
int led2 = A4;
int led3 = A5;
int led4 = A0;
long previousMillis = 0;     
int interval=1;
unsigned long currentMillis = 0;

void setup() {

  pinMode(led1, OUTPUT);  
  pinMode(led2, OUTPUT); 
  pinMode(led3, OUTPUT); 
  pinMode(led4, OUTPUT); 


} 

void loop() {

  currentMillis = millis();
  int PotValue = analogRead(A6);
  interval=PotValue*2/3;
  pattern1();
} 




void pattern1()
{
  if(currentMillis - previousMillis > interval*4){
    previousMillis = currentMillis;    
  }

  else if(currentMillis - previousMillis > interval*3) {
    digitalWrite (led1,LOW);
    digitalWrite (led2,LOW);
    digitalWrite (led3,LOW);
    digitalWrite (led4,HIGH);  
  }

  else if(currentMillis - previousMillis > interval*2) {
    digitalWrite (led1,LOW);
    digitalWrite (led2,LOW);
    digitalWrite (led3,HIGH);
    digitalWrite (led4,LOW);   
  }

  else if(currentMillis - previousMillis > interval) {
    digitalWrite (led1,LOW);
    digitalWrite (led2,HIGH);
    digitalWrite (led3,LOW);
    digitalWrite (led4,LOW);   
  }

  else if(currentMillis - previousMillis < interval) {
    digitalWrite (led1,HIGH);
    digitalWrite (led2,LOW);
    digitalWrite (led3,LOW);
    digitalWrite (led4,LOW);   

  }
}

When you don’t play with the potentiometer,everything goes fine.But while it is playing if you play with the potentiometer especially with fast motions,it makes ridiculous things,it stops sometimes it goes backwards.When I use delay(); to create interval,there is no problem with patterns but it waits for the delay to finish to response buttons and the potentiometer.So I was looking for a library.

  else if(currentMillis - previousMillis > interval) {
    digitalWrite (led1,LOW);
    digitalWrite (led2,HIGH);
    digitalWrite (led3,LOW);
    digitalWrite (led4,LOW);   
  }

  else if(currentMillis - previousMillis < interval) {

What happens if the difference between now and then is exactly interval? The last test looks stupid. That should be an else statement, not another else if.

But while it is playing if you play with the potentiometer especially with fast motions,it makes ridiculous things,it stops sometimes it goes backwards.

What do your serial prints tell you is happening? Why don’t you have any? Most importantly, why are you reading the potentiometer value on every pass through loop()? With the delay()s, you don’t read the potentiometer anywhere near that often.