Button help

So I am making an led display that will resemble fire and it includes 10 red led lights, I've wired them correctly and gotten them to work now all i need to do is make a button that will start the code when i hold it down and when i let go stop the loop i know to do a while loop but i don't know how to wire it its a larger button not one that fits directly on the breadboard. any help is much appreciated.

Thanks in advance,

If the switch doesn't fit on the breadboard, solder wires to it and take them to the breadboard.
Normally you make a digital pin an input with its internal PULLUP resistor enabled.
This pin goes to one side of the switch the other side goes to ground.

Select a pin for your input, lets just say pin 2, connect 1 wire from your button to pin 2.
Connect the other wire to ground.

void setup ()
{
  //Make pin 2 an input with pullup.
  pinMode(2, INPUT_PULLUP);
}

void loop ()
{
  int button;

  button = digitalRead(2);
  while(button);

  // fire here

}

Missing )

pinMode(2, INPUT_PULLUP);

klubfingers:
Select a pin for your input, lets just say pin 2, connect 1 wire from your button to pin 2.
Connect the other wire to ground.

void setup ()

{
  //Make pin 2 an input with pullup.
  pinMode(2, INPUT_PULLUP);
}

void loop ()
{
  int button;

button = digitalRead(2);
  while(button);

// fire here

}

What is PULUP? sorry I'm new to Arduino

INPUT_PULLUP enables the internal pullup resistors, so that the pin behaves as if there's a ~20k (right? something around there) pullup resistor between the pin and Vcc.

If we just set the pin INPUT, when the button was not pressed, the input will float - the value on it can be anything between Vcc and Gnd (the protection diodes keep it within that range), and will change depending on ambient electromagnetic fields (like an antenna). By putting a weak pullup on it, it is gently pulled up to Vcc when the switch is open, without interfering with behavior when it's closed.

This is how you usually will work with buttons and switches.

This may be of interest:
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

LarryD:
This may be of interest:
Inputs

So i set it up but it is not working no matter what i do the input is on i have it setup like this

void setup() {
  // put your setup code here, to run once:
 pinMode(2, OUTPUT);
 pinMode(1, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:
int button;
   
   button = digitalRead(1);
   while (button = HIGH) {
    digitalWrite(2, HIGH);
}
digitalWrite(2, LOW);
}

why is this not working the light is just on and pressing the button does nothing.

while (button = HIGH) {

Need ==

CrossRoads:
while (button = HIGH) {

Need ==

I did it

void setup() {
  // put your setup code here, to run once:
 pinMode(2, OUTPUT);
 pinMode(1, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:
int button;
   
   button = digitalRead(1);
   while (button == HIGH) {
    digitalWrite(2, HIGH);
}
digitalWrite(2, LOW);
}

but the outcome is still the same is my wiring off i have one wire from the switch to the number one digital output and one from the switch to ground next to pin 13?

0 and 1 tend to be high from being connected to the USB/Serial chip.
Change your logic to look for a LOW and wire the button to connect to Gnd when pressed.

CrossRoads:
0 and 1 tend to be high from being connected to the USB/Serial chip.
Change your logic to look for a LOW and wire the button to connect to Gnd when pressed.

ok that sort of worked but when i let go of the button the light just stayed on
and im not sure how to wire it to do that

Show the new code.

CrossRoads:
Show the new code.

oh right sorry

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(1, INPUT_PULLUP);
}
 
// the loop function runs over and over again forever
void loop() {
  int button;
   
   button = digitalRead(1);
   while (button == LOW) {
  digitalWrite(2, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(5, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);
  delay(50);    // wait for a second
  digitalWrite(3, HIGH);
  digitalWrite(6, LOW);
  delay(25);  // wait for a second
  digitalWrite(8, LOW);
  delay(25);
  digitalWrite(4, HIGH);
  digitalWrite(2, LOW);
  digitalWrite(10, HIGH);
  delay(50);    // wait for a second
  digitalWrite(5, HIGH);
  digitalWrite(3, LOW);  // turn the LED off by making the voltage LOW
  delay(25);  // wait for a second
  digitalWrite(10, LOW);
  delay(25);
  digitalWrite(6, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(9, HIGH);
  delay(50); 
  digitalWrite(2, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(5, LOW);
  digitalWrite(7, HIGH);
  delay(50);  // wait for a second
  digitalWrite(9, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(6, LOW);
  delay(25);  // wait for a second
  digitalWrite(7, LOW);
  delay(25);
  digitalWrite(4, HIGH);
  digitalWrite(2, LOW);
  digitalWrite(11, HIGH);
  delay(50);    // wait for a second
  digitalWrite(5, HIGH);
  digitalWrite(3, LOW);  // turn the LED off by making the voltage LOW
  delay(25);  // wait for a second
  digitalWrite(11, LOW);
  delay(25);
  digitalWrite(6, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(9, HIGH);
  delay(50); 
}
}

And you just want everything off when released?

digitalWrite(9, HIGH);
delay(50); 
}
// turn all off after all the delays conclude
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
digitalWrite (7, LOW);
digitalWrite (8, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (11, LOW);

}

CrossRoads:
And you just want everything off when released?

[color=#222222]  digitalWrite(9, HIGH);[/color][color=#222222][/color]

  delay(50);
}
// turn all off after all the delays conclude
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);

digitalWrite (6, LOW);

digitalWrite (7, LOW);

digitalWrite (8, LOW);

digitalWrite (9, LOW);

digitalWrite (10, LOW);

digitalWrite (11, LOW);

}
[color=#222222]

Yes and what are all the color things? and is this inside or outside the while

I don't know where all that stuff came from.
This goes near the end of your sketch, I copied your last two lines and the writes in, outside of the while.

Avoid using D0 and D1 in you sketches.
These are attached to your serial hardware.

Rather than using D1 use D12.

while (button == LOW)
{

//your on off stuff

digitalWrite(9, HIGH);
delay(50);
} // END of while

// add code turn off all the LEDs <----------<<<<

} //END of loop()

@Bob faster than a speeding bullet

CrossRoads:
I don't know where all that stuff came from.
This goes near the end of your sketch, I copied your last two lines and the writes in, outside of the while.

i did it but it still doesnt turn off

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(1, INPUT_PULLUP);
}
 
// the loop function runs over and over again forever
void loop() {
  int button;
   
   button = digitalRead(1);
   while (button == LOW) {
  digitalWrite(2, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(5, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);
  delay(50);    // wait for a second
  digitalWrite(3, HIGH);
  digitalWrite(6, LOW);
  delay(25);  // wait for a second
  digitalWrite(8, LOW);
  delay(25);
  digitalWrite(4, HIGH);
  digitalWrite(2, LOW);
  digitalWrite(10, HIGH);
  delay(50);    // wait for a second
  digitalWrite(5, HIGH);
  digitalWrite(3, LOW);  // turn the LED off by making the voltage LOW
  delay(25);  // wait for a second
  digitalWrite(10, LOW);
  delay(25);
  digitalWrite(6, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(9, HIGH);
  delay(50); 
  digitalWrite(2, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(5, LOW);
  digitalWrite(7, HIGH);
  delay(50);  // wait for a second
  digitalWrite(9, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(6, LOW);
  delay(25);  // wait for a second
  digitalWrite(7, LOW);
  delay(25);
  digitalWrite(4, HIGH);
  digitalWrite(2, LOW);
  digitalWrite(11, HIGH);
  delay(50);    // wait for a second
  digitalWrite(5, HIGH);
  digitalWrite(3, LOW);  // turn the LED off by making the voltage LOW
  delay(25);  // wait for a second
  digitalWrite(11, LOW);
  delay(25);
  digitalWrite(6, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(9, HIGH);
  delay(50); 
}

  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
}

Try D12 instead of D1

I assume the output pin goes to the LED anode then the LED cathode goes to a resistor (220) the other end of the resistor goes to GND.