Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: controlling multiple LEDs with 1 button (turns LEDs on in sequence) on: October 05, 2012, 10:02:16 pm
Thank you PaulS.

I know there are still other problems with the code as well..
The LED turns on when the button is pushed for the first time
Then it waits 10 secs after the second push to turn on..
(i still have to change the time to 15000 in the code)
2  Using Arduino / Programming Questions / Re: controlling multiple LEDs with 1 button (turns LEDs on in sequence) on: October 05, 2012, 09:59:24 pm
Code:
#define LED  13   // the pin for the LED
#define LED 12  //defining LED 12 here makes the whole thing doesn't work..not sure how to define
#define BUTTON 7  // the input pin where the
                 // pushbutton is connected
int val = 0;     // val will be used to store the state
                 // of the input pin
int old_val = 0; // this variable stores the previous
                 // value of "val"
int state = 0;   // 0 = LED off and 1 = LED on

unsigned long startTime = 0;

void setup() {
  pinMode(13, OUTPUT);   // tell Arduino LED is an output
  pinMode(7, INPUT); // and BUTTON is an input
}
void loop(){
  val = digitalRead(7); // read input value and store it

  // check if there was a transition
  if ((val == HIGH) && (old_val == LOW)){
    state = 1 - state;
    startTime = millis();
delay(10); }
  old_val = val; // val is now old, let's store it
  if (state == 0 && (millis() - startTime) < 10000) {
    digitalWrite(13, LOW); // turn LED OFF
  } else {
    digitalWrite(13, HIGH);
}


 if (state == 0 && (millis() - startTime) < 20000) {
    digitalWrite(12, LOW); // turn LED OFF
  } else {
    digitalWrite(12, HIGH);
  }}
3  Using Arduino / Programming Questions / controlling multiple LEDs with 1 button (turns LEDs on in sequence) on: October 05, 2012, 08:55:34 pm
Hello,

I'm a newbie at Arduino and I'm struggling with my project..
I want the one button to activate 10 LED in sequence. Each LED will turn on after 15 secs

push the button..
1st LED turns on after 15 secs
2nd LED turns on after 30 secs
and so on..

I got to the point where I can make the first LED turns on 15 secs after the button is pushed
but when I try to add the 2nd LED I'm missing something.. it doesn't turn on or anything..

Any suggestion would help.
Thank you!
Pages: [1]