user26676: I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital. 
Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.
How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.
int ledPin1= 2;
int ledPin2 = 4;
int ledPin3 = 7;

void setup(){
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  }

  void loop(){
  digitalWrite(ledPin1, HIGH);
  delay(500);
  digitalWrite(ledPin1, LOW);
  delay(500);

  digitalWrite(ledPin2, HIGH);
  delay(1000);
  digitalWrite(ledPin2, LOW);
  delay(1000);

  digitalWrite(ledPin3, HIGH);
  delay(1500);
  digitalWrite(ledPin3, LOW);
  delay(1500);
    }

So far this is the code. But it delays the whole program. Need leds on at given times. 

user24169: Seems like you want a pattern like this ?
LED1 : 1 0 1 0 1 0 1 0 1 0 1 0 ... repeat
LED2 : 1 1 0 0 1 1 0 0 1 1 0 0 ... repeat
LED3 : 1 1 1 0 0 0 1 1 1 0 0 0 ... repeat

In which case you'll need something like this pseudo code
// set up the relevant pins as output etc
....
// set up a counter
counter = 0

loop
  toggle LED1
  if (counter modulo 2 == 0) then toggle LED2
  if (counter modulo 3 == 0) then toggle LED3

  counter++
  if counter > 11 then counter = 0 // your pattern repeats every 12 seconds

  delay for 1 second

Toggling the LED is just a case of checking if it is high or low and setting it to the opposite value.

user26453: Using a 220k Ohm resistor will lead to approximatively 20µA to light the LED. This is not enough to light the LED, you should replace the resitor by one of value 330Ohm (220 to 470 could be OK depending of the LED) 

26676: <p>I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital. </p>

<p>Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.</p>

<p>How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.</p>

<pre><code>int ledPin1= 2;
int ledPin2 = 4;
int ledPin3 = 7;

void setup(){
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  }

  void loop(){
  digitalWrite(ledPin1, HIGH);
  delay(500);
  digitalWrite(ledPin1, LOW);
  delay(500);

  digitalWrite(ledPin2, HIGH);
  delay(1000);
  digitalWrite(ledPin2, LOW);
  delay(1000);

  digitalWrite(ledPin3, HIGH);
  delay(1500);
  digitalWrite(ledPin3, LOW);
  delay(1500);
    }
</code></pre>

<p>So far this is the code. But it delays the whole program. Need leds on at given times. </p>
 24169: <p>Seems like you want a pattern like this ?</p>

<pre><code>LED1 : 1 0 1 0 1 0 1 0 1 0 1 0 ... repeat
LED2 : 1 1 0 0 1 1 0 0 1 1 0 0 ... repeat
LED3 : 1 1 1 0 0 0 1 1 1 0 0 0 ... repeat
</code></pre>

<p>In which case you'll need something like this pseudo code</p>

<pre><code>// set up the relevant pins as output etc
....
// set up a counter
counter = 0

loop
  toggle LED1
  if (counter modulo 2 == 0) then toggle LED2
  if (counter modulo 3 == 0) then toggle LED3

  counter++
  if counter &gt; 11 then counter = 0 // your pattern repeats every 12 seconds

  delay for 1 second
</code></pre>

<p>Toggling the LED is just a case of checking if it is high or low and setting it to the opposite value.</p>
 26453: <p>Using a 220k Ohm resistor will lead to approximatively 20µA to light the LED. This is not enough to light the LED, you should replace the resitor by one of value 330Ohm (220 to 470 could be OK depending of the LED) </p>
