hello,
could anyone help me out (novice) with my sketch i have that i'm using to turn on some relays, all quite basic stuff i know but i'm still learning,
what i need is for the sketch to only start when it sees 12 volts coming in on a digital input, im already using pins 2 to 8 so i will use pin 9 as the input,
is this the best way to do what i want or is there a better way?
also the sketch should only run once then stop until it sees the input to start it again?
any help is very much appreciated
thanks
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int relay5 = 6;
int relay6 = 7;
int relay7 = 8;
void setup() {
pinMode (relay1,OUTPUT);
pinMode (relay2,OUTPUT);
pinMode (relay3,OUTPUT);
pinMode (relay4,OUTPUT);
pinMode (relay5,OUTPUT);
pinMode (relay6,OUTPUT);
pinMode (relay7,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (relay1, HIGH);
digitalWrite (relay2, HIGH);
digitalWrite (relay3, HIGH);
digitalWrite (relay4, HIGH);
digitalWrite (relay5, HIGH);
digitalWrite (relay6, HIGH);
digitalWrite (relay7, HIGH);
// flash all lights for 80 miliseconds to test for short circuit
delay (12000);
digitalWrite (relay1, LOW);
delay (80);
digitalWrite (relay1, HIGH);
delay (80);
digitalWrite (relay2, LOW);
delay (80);
digitalWrite (relay2, HIGH);
delay (80);
digitalWrite (relay3, LOW);
delay (80);
digitalWrite (relay3, HIGH);
delay (80);
digitalWrite (relay4, LOW);
delay (80);
digitalWrite (relay4, HIGH);
delay (80);
digitalWrite (relay5, LOW);
delay (80);
digitalWrite (relay5, HIGH);
delay (80);
digitalWrite (relay6, LOW);
delay (80);
digitalWrite (relay6, HIGH);
delay (80);
digitalWrite (relay7, LOW);
delay (80);
digitalWrite (relay7, HIGH);
delay (3000);