I am trying to get my pop headlamps to work with a 4 channel relay and a Arduino uno,
I don't know what i'm doing wrong, Any help would be appreciated.
const int buttonPin1 = 10;
const int buttonPin2 = 11;
const int relayPin1 = 2;
const int relayPin2 = 3;
// variables will change:
int buttonState1 = 0;
int buttonState2 = 0;
void setup() {
// initialize the LED pin as an output:
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
Serial.begin(9600);
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState1 == HIGH) {
// Motor to up positon:
Serial.println("UP");
digitalWrite(relayPin1, HIGH);
};
if (buttonState2 == HIGH) {
// Motor to down position:
Serial.println("Down");
digitalWrite(relayPin2, HIGH);
delay(1000);
}
else{
digitalWrite(relayPin1,LOW);
digitalWrite(relayPin2,LOW);
}
}