Side Mirror Control

Hi All,
I'm new to Arduino, my electrical skills are perfect but programming skills == LOW.
I'm programming my side mirrors to fold in one the doors are closed via the remote and fold out once reopen, also for the passenger side mirror to tilt down when the reverse is activated. after weeks of googling and copying and pasting and trying to learn and understand i came up with the below sketch;
Can someone please verify and point out where Im going wrong? or what you understand from this code??

[quote]


#define RELAY1  6                        

#define RELAY2  7                        

#define RELAY3  8                        

#define RELAY4  9

[color=#CC6600]const[/color] [color=#CC6600]int[/color] reversePin = 3;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] switchPin = 4;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] outputDown = 5;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] outputUp = 6;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] openPin = 7;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] closePin = 8;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] mirrorin = 9;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] mirrorout = 10;

[color=#CC6600]int[/color] inputPinState = [color=#006699]LOW[/color];
[color=#CC6600]int[/color] lastInputPinState = [color=#006699]LOW[/color];

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color] (){

  [color=#CC6600]pinMode[/color](reversePin, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](switchPin, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](openPin, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](closePin, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](outputDown, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](outputUp, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](mirrorin, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](mirrorout, [color=#006699]OUTPUT[/color]);
}


[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color](){
  inputPinState = [color=#CC6600]digitalRead[/color](reversePin);
  [color=#CC6600]if[/color] (inputPinState != lastInputPinState){
    [color=#CC6600]if[/color] (inputPinState == [color=#006699]HIGH[/color]){
      [color=#7E7E7E]//make outputDown HIGH for 3 seconds[/color]
      [color=#CC6600]digitalWrite[/color](outputDown, [color=#006699]HIGH[/color]);
      [color=#CC6600]delay[/color](3000);
      [color=#CC6600]digitalWrite[/color](outputDown, [color=#006699]LOW[/color]);
    }
    [color=#CC6600]else[/color] {
      [color=#7E7E7E]//make outputUP HIGH for 3 seconds[/color]
      [color=#CC6600]digitalWrite[/color](outputUp, [color=#006699]HIGH[/color]);
      [color=#CC6600]delay[/color](3000);
      [color=#CC6600]digitalWrite[/color](outputUp, [color=#006699]LOW[/color]);
    }
    lastInputPinState = inputPinState;
  }
}


[/quote]

Donfero posted code, some of which is shown below:

  digitalRead (openPin);
  digitalRead (closePin);
  digitalRead (switchPin);
  if (4 == LOW && 7 == HIGH && 8 == LOW)

This code:
Reads the openPin and throws the result away.
Reads the closePin and throws the result away.
Reads the switchPin and throws the result away.

Looks to see if LOW is four and eight (it is not and certainly cannot be both) and whether HIGH is seven (it is not). The condition of this 'if' statement will never be true.

Perhaps what was intended was something more like this:

  if ((digitalRead(switchPin)==LOW) && (digitalRead(openPin)==HIGH) && (digitalRead(closePin)==LOW))

Yes, some of the parentheses may be unnecessary but they make the intent clear to a reader.

Also:

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  5. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!