LEDs to blink independently of eachother

Hello,

I need a little software help.

First of all, I am using an Arduino Pro mini 328.

What I'm trying to do is have a 4017 decade timer run off one Digital pin with the delay of High/low output of the pin with a potentiometer (which I have working fine).

While those LEDs are blinking on the 4017, I also want a LED to blink at a set interval on another Digital pin.

Here is the code:

int ledPin9 = 9; // LED connected to digital pin 09
int ledPin10 = 10; // LED connected to digital pin 10
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
//Digital Pin 9 - 4017 decade counter for the screen display
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 50);
digitalWrite(ledPin9, HIGH); // set the LED on
delay(val); // wait for the val of the pot
digitalWrite(ledPin9, LOW); // set the LED off
delay(val); // wait for the val of the pot

//Digital Pin 10 - blinking LED
digitalWrite(ledPin10, HIGH); // set the LED on
delay(500); // wait for half a second
digitalWrite(ledPin10, LOW); // set the LED off
delay(500); // wait for half a second
}

What I'd like to happen would be the LED on Digital pin 10 to blink independently of what's happening on Digital pin 9. Because the way I have the code now, it doesn't matter what "val" equals, because the loop always waits for the 500 ms of the blinking LED before it loops again. This makes the potentiometer speed control of the 4017 pointless.

Is there any way to get the two to work independently of each other? So I can vary the speed of the 4017 with the potentiometer while the LED on pin 10 steadily blinks every 500ms?

Thanks for the help!

Check out the Blink Without Delay example

and expand on it.
Make sure you understand the single LED example before you try more LEDs

You could have a look here:
http://www.arduino.cc/playground/Main/GeneralCodeLibrary#Timing_code
:slight_smile:

Thank you very much for the help. It has been a while since I've done any C++ programming (back in high school) and I'm still not familiar with all the functions available for the arduino.

I appreciate you guys pointing me in the right direction.