Go Down

Topic: [BASIC] [LED] Making two LEDs light at once (Read 1 time) previous topic - next topic

Flafee

I'm trying to make two LEDs light up at once, on two different pins.

This is what I have written for my 6 LED sequence testing.

Code: [Select]
const int pin1 = 3;
const int pin2 = 4;
const int pin3 = 5;
const int pin4 = 6;
const int pin5 = 7;
const int pin6 = 8;

void setup()
{
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
}

void loop()
{
  digitalWrite(pin1, HIGH);
  delay(100);
  digitalWrite(pin1, LOW);
  digitalWrite(pin4, HIGH);
  delay(100);
  digitalWrite(pin4, LOW);
  digitalWrite(pin2, HIGH);
  delay(100);
  digitalWrite(pin2, LOW);
  digitalWrite(pin5, HIGH);
  delay(100);
  digitalWrite(pin5, LOW);
  digitalWrite(pin3, HIGH);
  delay(100);
  digitalWrite(pin3, LOW);
  digitalWrite(pin6, HIGH);
  delay(100);
  digitalWrite(pin6, LOW);
  delay(2000);
 
 
  digitalWrite(pin1, HIGH);
  delay(100);
  digitalWrite(pin1, LOW);
  digitalWrite(pin2, HIGH);
  delay(100);
  digitalWrite(pin2, LOW);
  digitalWrite(pin3, HIGH);
  delay(100);
  digitalWrite(pin3, LOW);
  digitalWrite(pin6, HIGH);
  delay(100);
  digitalWrite(pin6, LOW);
  digitalWrite(pin5,HIGH);
  delay(100);
  digitalWrite(pin5, LOW);
  digitalWrite(pin4, HIGH);
  delay(100);
  digitalWrite(pin4, LOW);
  delay(500);
 
  digitalWrite(pin4, HIGH);
  delay(100);
  digitalWrite(pin4, LOW);
  digitalWrite(pin5, HIGH);
  delay(100);
  digitalWrite(pin5, LOW);
  digitalWrite(pin6, HIGH);
  delay(100);
  digitalWrite(pin6, LOW);
  digitalWrite(pin3, HIGH);
  delay(100);
  digitalWrite(pin3, LOW);
  digitalWrite(pin2, HIGH);
  delay(100);
  digitalWrite(pin2, LOW);
  digitalWrite(pin1, HIGH);
  delay(100);
  digitalWrite(pin1, LOW);
  delay(2000); 
}


I want to pin1 and pin4 light up at the same time. I can't figure out how to make it happen.

larryd

Quote
I want to pin1 and pin4 light up at the same time

Code: [Select]

digitalWrite(pin1, HIGH);
digitalWrite(pin4, HIGH);
delay(100);
digitalWrite(pin1, LOW);
digitalWrite(pin4, LOW);
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Flafee

Of course it would be that simple.... It was looking me straight in the face. Thank you very much!

larryd

When you are ready to look at Arrays look here:
http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

Thanks Mike!
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Go Up