Enclose its currency control program relays group so that the first works after receipt switch no. 1 and after separation switch no. 1 and second delivery and after a certain time working the second Relay and so on for the third and fourth, but when I brought the switch no. 1, works first relay, after a period and at the same time the second relay off, but I want to extinguish the second and after the relay no.1 works, and so any first controls the second, third, fourth and so on.
program
const byte coils[4] = {2, 3, 4, 5};
const byte switches[4] = {6, 7, 8, 9};
const unsigned long period = 5000;
unsigned long p = 0;
byte d = 9;
void setup()
{
for (byte u = 0; u < 4; u++)
{
pinMode(coils, OUTPUT);
pinMode(switches, INPUT_PULLUP);
}
for (byte h = 0; h < 4; h++)
{
digitalWrite(coils, HIGH);
}
}
void loop()
{
for (byte i = 0; i < 4; i++)
{
if (digitalRead(switches*) == LOW)*
* {*
* if (i == 0)*
* {*
* p = millis();*
* while (millis() - p <= period);*
_ digitalWrite(coils*, LOW);*_
* for (byte f = 0; f < 4; f++)*
* {*
* if (f != i)*
* digitalWrite(coils[f], HIGH);*
* }*
* }*
* else*
* {*
* if (digitalRead(coils[0]) == HIGH)*
* {*
* if (i == 1)*
* {*
* p = millis();*
* while (millis() - p <= period);*
_ digitalWrite(coils*, LOW);*_
* for (byte f = 0; f < 4; f++)*
* {*
* if (f != i)*
* digitalWrite(coils[f], HIGH);*
* }*
* }*
* if((i==2)&&(digitalRead(coils[1]) == HIGH))*
* {*
* p = millis();*
* while (millis() - p <= period);*
_ digitalWrite(coils*, LOW);*_
* for (byte f = 0; f < 4; f++)*
* {*
* if (f != i)*
* digitalWrite(coils[f], HIGH);*
* }*
* }*
* if((i==3)&&(digitalRead(coils[1]) == HIGH)&&(digitalRead(coils[2]) == HIGH))*
* {*
* p = millis();*
* while (millis() - p <= period);*
_ digitalWrite(coils*, LOW);*_
* for (byte f = 0; f < 4; f++)*
* {*
* if (f != i)*
* digitalWrite(coils[f], HIGH);*
* }*
* }*
* }*
* }*
* }*
* else*
* {*
_ digitalWrite(coils*, HIGH);*_
* }*
* }*
}