Learning how to program

I want to have a pushbutton turn on a light then delay then turn on another light so far I got to turning on just one light is there an AND function to do this. (Remember this is just my second day of leaning to program) THANX!

There is an and operator (&&), but it is probably not what you want to do.

Post the code you have now, and explain where and when you want to turn on the second pin.

What you want is something like:

blah blah blah... digitalWrite(light_one_pin, HIGH); // turn on the first light delay(5000); // wait 5 seconds (5000 msec) digitalWrite(light_two_pin, HIGH); // turn on second light. blah blah blah...

Even though you didn't know exactly hw to do it, you have the right idea.. your explanation of what you want to do translates directly into code. Just like you said, all you need to add is the delay and the command to turn on the second light ;)

have you seen the delay() function?

///////////////////////////////////////////////////// ///////////DEFINITIONS//////////////////////////////

define LED1 10 // the pin for the LED

define LED2 11

define BUTTON 7 // the input pin where the pushbutton is connected

///////////////////////////////////////////////////// //////////////////////////////////////////////////// int val = 0; //val will be used to store the stat of the input pin

void setup() { pinMode(LED1, OUTPUT); //tells Arduino LED is an output pinMode(LED2, OUTPUT);

pinMode(BUTTON, INPUT); // and BUTTON is an input }

void loop() {

val = digitalRead(BUTTON); // read input value and store

//check whether the input is HIGH (button pressed) if (val == HIGH) { digitalWrite(LED1, HIGH);} //turn LED on else { digitalWrite (LED1, LOW);} // keeps light off when not pressed

// ????????

// I want the second light to come on after a delay

Please use the when posting code! :)

Also for good spirit:

/////////////////////////////////////////////////////
///////////DEFINITIONS//////////////////////////////
#define LED1 10    //  the pin for the LED
#define LED2 11
#define THEDELAY 2000
#define BUTTON 7  // the input pin where the pushbutton is connected
/////////////////////////////////////////////////////
////////////////////////////////////////////////////
int val = 0;      //val will be used to store the stat of the input pin


void setup()
{
  pinMode(LED1, OUTPUT);    //tells Arduino LED is an output
  pinMode(LED2, OUTPUT);

  pinMode(BUTTON, INPUT);  // and BUTTON is an input
}

void loop() {
  val = digitalRead(BUTTON);  // read input value and store

  //check whether the input is HIGH (button pressed)
  if (val == HIGH) {
    digitalWrite(LED1, HIGH);
    delay(THEDELAY);
    digitalWrite(LED2, HIGH);
  } else { 
    digitalWrite (LED1, LOW);
    digitalWrite (LED2, LOW);
  } // keeps light off when not pressed
 }

First things, first. If you put your curly braces ({}) on separate lines, and indent your code properly (the IDE can even help you do that), you will see that where you have the comments is NOT where you want to add code.

As was mentioned, a delay() call and then another digitalWrite() will turn a second LED on after a suitable interval.

However, you'll see that the system is not responsive to button pushes during that delay.

If this is an issue for you, and it generally is, see the Blink Without Delay example.

void loop() {

val = digitalRead(BUTTON); // read input value and store

//check whether the input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED1, HIGH); //turn LED on
delay(5000);
digitalWrite(LED2, HIGH); //turns on LED after a delay
}

else
{
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
}

// I got the lights to sequence but only if I keep holding the button
What would I insert as a latching code.

If PaulS is right I might humbly suggest http://www.arduino.cc/playground/Code/Scheduler. Then you can easily schedule a function (that sets pin2 high) and do other things in the meanwhile :)

   digitalWrite(LED1, HIGH);  //turn LED on
   delay(5000);
   digitalWrite(LED2, HIGH);  //turns on LED after a delay
   delay(5000); //it will light for 5 seconds

Thanks for the help I got it now.

Great. Programming is mainly about breaking down a problem into small enough pieces to handle easily. Then it's just a matter of solving a series of simple problems. I think it was a Calc teacher that told me that, but it holds true for any "complex" problem.

You already had your answer.. you just hadn't gotten the syntax of how to say it yet. Getting the answer is the important part, the syntax just takes a little practice.