LED sequence help

im trying to build a LED sequence that is triggered by a push button... i seem to only find "loops" if i could build one that the chase speed is controlable some how.... can anyone help point me in the right direction as to where i can get info to build something along these lines? thank you all...

Can you diuscribe it some more, what would the user do and what would the result be?

im trying to do two things....

one would be "pull a trigger" and have a simple chase across a series of LED lights...one to the next....

the second thing i would want to do (same system or a different build) be able to pull the trigger and go down the sequence one LED to the next down the series of LEDs pull trigger, first LED lights up....pull again, first LED goes out, second comes on...etc

if i could do it through the same chip, that would be awesome...but if not, i would try to do each on seperate chips....

Write some code in the setup() function that does what you want with the LEDs, every time you reset the Arduino the code will run and you can test it.

When it works cut the code out and create a function from it. Then add code in loop() that tests for a button to be pressed and calls that function.

void fireLEDs () {
 // your LED code here
}

void loop () {
    if (digitalRead(triggerPin) == HIGH)
       fireLEDs();
}

Rob

what is the best set up for what i am trying to do? im new at this.... thank you in advanced for helping point me in the right directions

what is the best set up

First question, how many LEDs?


Rob

Start simple and build from there... Most "real" computer programs are written and debugged this way.

Take a look at the [u]Arduino Language Reference[/u] and some of the associated examples. You'll want to look at input/output (how to detect a button-push and how to turn-on an LED). You'll also want to look how if-statements work. (If the LED is off and I push the button, do something...)

And, you'll need to know a little about timing and delays.

I'd start by making a program (sketch) that turns-on an LED when you push the button/switch and off when you release it. Then, make a program that turns the LED on when you push the button once, and turns-off when you push the button again. (Mechanical buttons "bounce" for a few milliseconds, so you'll need a delay for that one.)

Now, write a little sketch that sequences LEDs. The Bitwise Operators and bits & Bytes functions might also be helpful. In binary (base 2), a looping 4-channel "chase" looks like this:

0001 (=1 decimal)
0010 (=2 decimal)
0100 (=4 decimal)
1000 (=8 decimal)
0001
0010
0100
1000
0001
0010
0100
1000...

Take a look at [u]blikenlight Experiments[/u].

if i could do it through the same chip, that would be awesome...but if not, i would try to do each on seperate chips....

You should be able to do both, depending on how many LEDs are in your sequence. And, there are ways to increase the number of LEDs you can drive/control.

I know some will freak out a little about the use for a Fritzing image, but as a noob I found it really helped me understand the schematics.
Sorry if this causes anyone to stress out, ok.

I got the basic hardware debounce worked out. Thanks to http://www.ikalogic.com/debouncing.php

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);     // that orange wire
  pinMode(13, OUTPUT); 
}
void loop() {
  boolean sensorValue = digitalRead(2);
  Serial.println(sensorValue);
  sensorValue=!sensorValue;  //  I inverse this so the LED is off when no button pressed and on when pressed.
  digitalWrite(13,sensorValue);
}

Digitalduino: Arduino Software and Hardware Based Button Debouncing is a great article on debouncing.
It says "Changing the size of the cap will change how long it takes to charge, and thus, how long it takes the digital to become "HIGH"."

It also has the resistor at the ground end of the circuit.

hardware debounce.png

i have built something similar to this before....but what im trying to do is push the button and have it trigger a squence of led lights to flash on, then off...one at a time.... atleast 6-10 LED lights

Sounds easy, the basic logic is like this code.

viod setup()
{
 for (int ledpin=2; ledpin <= 10; ledpin++)  // loop through 8 digital pins (2-10) setting them to output
      {
        pinMode(ledpin, OUTPUT);
      }
  pinMode(11,INPUT)  // The button is connected to pin 11
} // setup

void loop()
{
   boolean buttonState = digitalRead(11); // get button state
   buttonState =! buttonState;            // Invert button state to match logic
  if (buttonState == true){
    for (int ledpin=2; ledpin <= 10; ledpin++)  // loop through them 8 led pins
      {
        digitalWrite(ledpin,HIGH);  // turn led on
        delay(333)                       // wait 1/3 of a second
        digitalWrite(ledpin,LOW);  // turn led off
      }  // for
  }  // if button
} // loop