avoiding delay

hello guys

I'm new with arduino
I've made a button which controls two leds.
I want one led to stay on for three seconds and the other one for 10 seconds.
I want to avoid delay because I don't want my entire program to stop

can anybody help me out?

many thanks in advance

Look at the BlinkWithoutDelay example in the IDE

dijkie350:
can anybody help me out?

What have you tried so far: what worked, what didn't?

I looked at the example with the blinking led and at the millis() in te reference.
so far I didn't manage to get this in my sketch.

This thread should probably be a sticky post:

http://forum.arduino.cc/index.php?topic=223286.0

dijkie350:
I looked at the example with the blinking led and at the millis() in te reference.
so far I didn't manage to get this in my sketch.

Well as I said before....

JimboZA:
What have you tried so far: what worked, what didn't?

.... what code have you tried? Post it here, and explain what it's (not) doing. Also post a schematic of your circuit: we need to see how the button is connected.

I just used this simple button sketch, only with a led added.
everything is working fine so far.
now I have to keep te leds on.
one for three seconds and the other for fifteen for example

// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 2;    
const int belPin =  12;      
const int rgbPin = 11;

int buttonState = 0;
void setup() {
  
  // initialize the LED pin as an output:
  pinMode(belPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);  
  pinMode(rgbPin, OUTPUT);  
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {     
    digitalWrite(belPin, HIGH);
    digitalWrite(rgbPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(belPin, LOW); 
     digitalWrite(rgbPin, LOW);
  }
  
}

polymorph:
This thread should probably be a sticky post:

Demonstration code for several things at the same time - Project Guidance - Arduino Forum

moderator: done

Yay!

robtillaart:
moderator: done

Thank you.

It's a rather long Thread with a lot of esoteric discussion. I hope newcomers start at the first (oldest) post.

...R

Robin2:

robtillaart:
moderator: done

Thank you.

It's a rather long Thread with a lot of esoteric discussion. I hope newcomers start at the first (oldest) post.

...R

I expect they still start with posting their problem first :wink: