If I start the program both relays are ON, but I want that one of them are ON when I start the program. The buttons themselves are working as I want to.
I can somebody tell what to add to the code? Starting values?
My code ise here:
int Relay1 = 5;
int Relay2 = 6;
int buttonApin = 9;
int buttonBpin = 8;
byte leds = 0;
void setup()
{
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, LOW);
}
if (digitalRead(buttonBpin) == LOW)
{
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, HIGH);
}
}
Why is it that only the OP, with his first ever post on these forums, used code tags, and everyone else with more experience posted it inline? Setting a bad example.