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]