2 LED blink seperatly

Hello I need some help on a project.

The project is: I have two LED's and want them to blink. The delay of the LED's can be set with a potentiometer. You can switch with a switch, with LED you want to change the delay. But here comes the problem, the other LED has to keep blinking with the same frequency.
I put my code at the bottom, but it doesn't work. Please help!

#include <Scheduler.h>

int potPin = 2;
int aValue = 0;
int bValue = 0;
Scheduler scheduler = Scheduler();

void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
digitalWrite(3, 1);
digitalWrite(4, 1);
}

void loop() {
scheduler.update();
if (digitalRead(3) == HIGH) {
aValue = analogRead(potPin);
digitalWrite(6, HIGH);
delay(aValue);
digitalWrite(6, LOW);
delay(aValue);
}

void loop2() {
if (digitalRead(4) == HIGH) {
bValue = analogRead(potPin);
digitalWrite(7, HIGH);
delay(bValue);
digitalWrite(7, LOW);
delay(bValue);
}
}

Using delay()s will screws up your Scheduler
Don't use delay()

What is loop2() doing there?

You can't use delay() because your sketch basically stops running during the delay time. For that reason, it's somewhat rare for real-world programs to use delay(), unless it's a very-short delay.

Take a look at the [u]Blink Without Delay Example[/u].

I'd suggest you start by simply adding a 2nd LED with it's own interval. i.e. You'll need two variables such as interval1 and Interval2, two ledState variables, and two previousMillis variables. (I've written some sketches with several different timers running at the same time.)

Once you get two LEDs blinking at two different rates, you can add switches & pots and the associated code.

Have you lookded at Arduino Playground - Scheduler Library ?

Edit your post and insert the sketch between code tags.
Use the Code icon.

2014-11-19_21-59-49.jpg

Here is a section of code you can modify:

#include <Scheduler.h>

//change an or add as per your hardware requirements
const byte potPin   = A0;
const byte led1     = 2;
const byte switch1  = 3;
boolean led1State = true; //when true this indicates the led is off

//create instances
Scheduler scheduler = Scheduler();    //used for led1
Scheduler scheduler2 = Scheduler();   //used for led2

void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  digitalWrite(led1, LOW); //LED is off at start up, depends on the led wiring
  led1State = true;  
  pinMode(switch1, INPUT);

}// END of setup()

void loop() 
{
  scheduler.update();  
  scheduler2.update(); 

  //if the switch is pressed and the led is now off
  if (digitalRead(switch1) == HIGH && led1State == true)
  {
    //disable a re-trigger form occurring
    led1State = false;
    //schedule the led to go on after the delay time read from the pot
    scheduler.schedule(setled1High,analogRead(potPin)); 
  }

} // END of loop()

//LED on
void setled1High()
{
  //turn the led on
  digitalWrite(led1,HIGH);         
  //schedule the led to go off after the delay time read from the pot
  scheduler.schedule(setled1Low,analogRead(potPin)); 
} 

//LED off
void setled1Low()
{
  //turn the led off
  digitalWrite(led1,LOW);   
  //enable a re-trigger
  led1State = true;
}

Have a look at this video.

The demo several things at a time (which is a sticky at the top of this section of the Forum) does a lot of what you want straight out of the box.

...R

Can you add the line of code Serial.begin(9600) and Serial.println() and send us the results?

That would be what you have to do:

void setup(){
  Serial.begin(9600); //add that line to the SETUP
}

void loop(){
  Serial.println(aValue); //add that line to the LOOP
}

Please send me a screenshot of the serial monitor so that I can see aValue with more detail.

Thanks, an Arduino fan