hello all, My name is Brad, thank you in advance for any help.
My Project is making a Plow control.
what I am trying to do is as follows;
arduino uno rv3 with relay shield.
using 4 momentary buttons to control relays.
I have done some code for the relays and seem to have each relay working on each button.
problem is when i go further to change code to make relays turn on the way i need is not working out.
what im trying to do is button 1 is up
button 2 is for down
button 3 is for right
button 4 is for left
i am trying to combine ; ie when button 3(right) or button 4(left) is pressed i need it to turn on its respective relays as well as relay 1 (up). so push 3 and get 3 and 1. push 4 and get 4 and 1. after i get this worked out i need to set delays for relay 1(up).
I will add a pic of my board as well as my starting code that I have so far. I have tried multiple ways of doing this but keep getting relay 1(up) blinking instead of staying on like i wish...
please let me know if u need any further info.
again thanks so much for any help.
#define relay1 7
#define relay2 6
#define relay3 5
#define relay4 4
#define up 11
#define down 10
#define right 9
#define left 8
void setup() {
Serial.begin(9600);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(up, INPUT);
pinMode(down, INPUT);
pinMode(right, INPUT);
pinMode(left, INPUT);
}
void loop() {
if(digitalRead(up)==1){
Serial.println("up");
digitalWrite (relay1, HIGH);
delay(100);
}
else{
digitalWrite (relay1, LOW);
}
if(digitalRead(down)==1){
Serial.println("down");
digitalWrite (relay2, HIGH);
delay(100);
}
else{
digitalWrite (relay2,LOW);
}
if(digitalRead(right)==1){
Serial.println("right");
digitalWrite (relay3, HIGH);
delay(100);
}
else{
digitalWrite (relay3, LOW);
}
if(digitalRead(left)==1){
Serial.println("left");
digitalWrite (relay4, HIGH);
delay(100);
}
else{
digitalWrite (relay4, LOW);
}
delay(100);
}