Yes this is exactly what i need but i need to make sure during that transition between state 2 and 3 when both high and low beam inputs are low that the low beams stay on
const byte powersenseIn = 9;
const byte highbeamIn = 10;
const byte lowbeamOut = 11;
const byte highbeamOut = 12;
void setup()
{
pinMode (powersenseIn, INPUT_PULLUP);
pinMode (highbeamIn, INPUT_PULLUP);
pinMode(lowbeamOut, OUTPUT);
pinMode(highbeamOut, OUTPUT);
}
void loop()
{
if (digitalRead(powersenseIn) == HIGH) //if the headlights are on
{
digitalWrite(lowbeamOut, HIGH); //turn on low beam
if (digitalRead(highbeamIn) == HIGH) //if high beam selected
{
digitalWrite(highbeamOut, HIGH); //turn on high beam
}
}
else //headlights are off
{
digitalWrite(lowbeamOut, LOW); //turn off low beam
digitalWrite(highbeamOut, LOW); //turn off high beam
}
}
You will need to ensure that the input voltages are between 0V and 5V, that not more than a few milliamps is taken from the outputs and that the Arduino is supplied with a stable voltage that contains no spikes.
I still think that it is a waste of an Arduino.