how stop loop with buton

im a newbie on arduino and programing i try to build

4button to:
1.start
2.stop
3.start when push
4.count when push

and use 7 relay for output
but imake sample to start and stop
the loop not works

the sample:

boolean mySet1 = false;
boolean mySet2 = false;

const int button1 = 18;// connect output to push button
const int button2 = 19;// connect output to push button
const int button3 = 20;// connect output to push button
const int button4 = 35;// connect output to push button

const int buttonlimit1 = 45;// connect output to push button
const int buttonlimit2 = 46;// connect output to push button
const int buttonlimit3 = 47;// connect output to push button
const int buttonlimit4 = 48;// connect output to push button
const int buttonlimit5 = 49;// connect output to push button
const int buttonlimit6 = 50;// connect output to push button
const int buttonlimit7 = 51;// connect output to push button

int relay1 = 28;// Connected to relay (LED)
int relay2 = 29;// Connected to relay (LED)
int relay3 = 30;// Connected to relay (LED)
int relay4 = 31;// Connected to relay (LED)
int relay5 = 32;// Connected to relay (LED)
int relay6 = 33;// Connected to relay (LED)
int relay7 = 34;// Connected to relay (LED)

boolean myButton1;
boolean myButton2;

void setup() {
// DK INSTRUMENTS
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
pinMode(buttonlimit1, INPUT_PULLUP);
pinMode(buttonlimit2, INPUT_PULLUP);
pinMode(buttonlimit3, INPUT_PULLUP);
pinMode(buttonlimit4, INPUT_PULLUP);
pinMode(buttonlimit5, INPUT_PULLUP);
pinMode(buttonlimit6, INPUT_PULLUP);
pinMode(buttonlimit7, INPUT_PULLUP);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);

}
void loop() {

myButton1=digitalRead(button1);

if (myButton1==true) mySet1 = true; // set bolean to true
else
mySet1=false;

digitalWrite(relay1, mySet1);
delay(10000);

digitalWrite(relay2, mySet1);
digitalWrite(relay3, mySet1);

delay(10000);

digitalWrite(relay4, mySet1);
digitalWrite(relay5, mySet1);

delay(10000);

digitalWrite(relay4, LOW);
digitalWrite(relay5, LOW);

delay(10000);

digitalWrite(relay6, mySet1);
digitalWrite(relay7, mySet1);

delay(10000);
digitalWrite(relay6, LOW);
digitalWrite(relay7, LOW);

delay(10000);

digitalWrite(relay1, LOW);
delay(10000);

myButton2=digitalRead(button2);
if (myButton2==true) mySet2 = true; // set bolean to true
else
mySet2=false;

while(digitalRead(button2) == LOW) {
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
digitalWrite(relay5, LOW);
digitalWrite(relay6, LOW);
digitalWrite(relay7, LOW);

delay(1);
}

}

plese guide ,,,thanks

How to use this forum - please read

Do note that during the 1 minute and 10 seconds worth of delay in that loop, nothing is checking the buttons. If you want programs to be responsive to human input then you can't use delay.

sory for thats.....its my first post..

you have idea ??the delay was i set high because on proteus this run to fast....thanks for reply!

boedi:
sory for thats.....its my first post..

What a perfect time to read the forum rules don't you think? Always best to read the instructions BEFORE you get started on something.

boedi:
you have idea ??the delay was i set high because on proteus this run to fast....thanks for reply!

Yes, handle the timing without delay. It's only mentioned on this site like 10,000 times per day. Google "Blink Without Delay"

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Have you actually programmed a controller and tried your code, or are you doing it all in a virtual world in a simulator package?

Thanks.. Tom... :slight_smile: