Go Down

Topic: How to change loop or create a second loop (Read 522 times) previous topic - next topic

primoz-2

Hi. I'm new at arduino and programming :) I wanna to learn it so i wrote a simple digital output for two leds to  blink on and off in 1 second delay. I wanna add a third led to blink independent on those two in loop, but i don't know how to do it  :~


Tnx for help in advance :)

codlink

How to use this forum

We would have to see your code.  Please, post it in code tags.
//LiNK

AWOL

There's a very simple example of how to blink a LED without using "delay()" in the examples in the IDE.
You can extend the technique to several LEDs, but I advise you to start with just two.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

primoz-2

#3
Apr 03, 2013, 07:49 pm Last Edit: Apr 03, 2013, 08:10 pm by primoz-2 Reason: 1
Code: [Select]
int led1 = 0;
int led2 = 1;
int led3 = 2;

void setup()
{
  pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}

void loop()
{
  digitalWrite(led1, HIGH);
  delay(1000);
 
  digitalWrite(led1, LOW);
 
  digitalWrite(led2, HIGH);
  delay(1000);
 
  digitalWrite(led2, LOW);
  delay(1000);
  digitalWrite(led3, HIGH);
  digitalWrite(led3, LOW);
}


UKHeliBob

Please edit that post, select the code and click the code tag button (# above the smileys)

Have you looked at the BlinkWithoutDelay example as suggested ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

wildbill

Use of delay will prevent you doing what you're trying to do. AWOL's advice will take you right to the solution though.

primoz-2

Tnx for answers! Awol i don't understand what u mean with: without using "delay()" in the examples in the IDE. I just delete delay();  or how? Sorry i'm newbe :)

AWOL

Look at the blink without delay example in the IDE.
It performs a slow flash of a LED without calling delay().
Play around with the example, and/or have a look at Nick Gammon's blink tutorial.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


Go Up