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