a small and easy program but went wrong

Hi all....
I have the VBB program so will i was testing my solenids i had a problem with the program and here it is....

int voltone = 2;
int volttwo = 4;

void setup() {
 
  Serial.begin(9600);
  
  pinMode(voltone, OUTPUT);
  pinMode(volttwo, OUTPUT);
}


void loop() {
  
  digitalWrite(voltone, HIGH);   
  delay(1000);               
  digitalWrite(volttwo, HIGH);    
  delay(1000);
  digitalWrite(voltone, LOW);
  digitalWrite(volttwo, LOW);
}

what am i expecting from this code is to set one "LED"(for example) on then wait then set the other "LED 2" on then turn off LED and finally turn off LED2 .... but that is not what i'm getting! ..... what i'm getting is this.... LED is on and remain on while LED2 blinks with no end... :frowning:

please help

Think about what your program is doing:

forever:
Turn led 1 on
wait
Turn led 2 on
wait
Turn led 1 off
Turn led 2 off
repeat.

Waiting a bit after turning them off might matter.

Your code is good! Up to a point.

What is happening is that after you turn both LEDs OFF, you need another delay to see it. Just add another delay(1000) at the bottom of the code.

What is happening right now is that LED1 is turned OFF at the bottom of the code and right back ON at the top.

Good luck!

ahaa.... so its just the delay which will make me see what actually happens

Yes. Another way to look at it is that the time between the end of "void loop()" and the beginning of it, is almost zero. That's the "loop" part :slight_smile:

Yes. Another way to look at it is that the time between the end of "void loop()" and the beginning of it, is almost zero. That's the "loop" part :slight_smile:

yep... thanks :slight_smile: