noob help with buttons.

I literally just started yesterday on learning the arduino language but i know a good amount of css and javascript so i understand how the format works and i kinda get how to do things on the arduino. the one thing I'm trying to do is set an input command on a button that starts a void loop when pressed. kind of like an ignition button on some cars. what i have setup is:

int button = 5; int led = 9;

void setup(){ pinMode(button, INPUT); pinMode(led, OUTPUT }

void loop(){ digitalWrite(led, HIGH); delay(0500); digitalWrite(led, LOW); delay(0500); }

what i need to figure out is how to start void loop with int button command which i have had no luck tinkering with the lines. any help will be most appreciated!

i also added int button2 = 7; pinMode(button2, OUTPUT)

digitalWrite(button2, HIGH);

so the button has an input and output but i still dont know how to get it to engage the loop and whatnot.

You need another loop. I'd probably use a while() loop. Run a "do nothing" while loop and break-out of the loop and continue when the button is pushed.

the loop is always running however you can go to a function put this in loop IF (button=HIGH){dosomething()} below loop void dosomething() {digitalWrite(led,high) }

kind of what i want but i dont want void loop to stop. i want it to start but not stop until i hit reset. kind of a governing command.

shooter: the loop is always running however you can go to a function put this in loop IF (button=HIGH){dosomething()} below loop void dosomething() {digitalWrite(led,high) }

ill give this a try.

ok so that didnt work. it just automatically blinks as soon as i upload the code.

this is the code i set

int button = 5; int led = 9; int button2 = 7;

void setup() {

pinMode(button, INPUT); pinMode(button2, OUTPUT); pinMode(led, OUTPUT); digitalWrite(button2, HIGH); } void loop(){ if (button=HIGH){dosomething();} }

void dosomething(){

digitalWrite(led, HIGH); delay(0500); digitalWrite(led, LOW); delay(0500);

}