Hi All
I have an Arduino running in my car to close, open and tilt the mirrors.
the open and close function work from the FOB, opens when the doors are unlocked and closes when the doors are locked. I want to modify the code so the mirrors close when I double click the close button, so basically when
pinMode(close_pin,INPUT);
is pressed twice.
here is the code
#define reverse_pin 5
#define switch_pin 6
#define close_pin 2
#define open_pin 12
#define tiltup_pin 9
#define tiltdn_pin 10
#define m1_pin 7
#define m2_pin 8
#define tilttmr 1630
#define closetmr 2600
boolean tiltuplock=false,closemrrlk=true;
void setup (){
pinMode(reverse_pin,INPUT);
pinMode(switch_pin,INPUT);
pinMode(close_pin,INPUT);
pinMode(open_pin,INPUT);
pinMode(tiltup_pin,OUTPUT);
pinMode(tiltdn_pin,OUTPUT);
pinMode(m1_pin,OUTPUT);
pinMode(m2_pin,OUTPUT);
digitalWrite(tiltup_pin,LOW);
digitalWrite(tiltdn_pin,LOW);
digitalWrite(m1_pin,LOW);
digitalWrite(m2_pin,LOW);
}
void loop(){
if(digitalRead(switch_pin)){
if(digitalRead(reverse_pin)&&tiltuplock){//Tilt down
delay(300);
if(digitalRead(reverse_pin)){
tiltuplock=false;
digitalWrite(tiltdn_pin,HIGH);
delay(tilttmr);
digitalWrite(tiltdn_pin,LOW);
}
}
if(!digitalRead(reverse_pin)&&!tiltuplock){//Tilt up
tiltuplock=true;
digitalWrite(tiltup_pin,HIGH);
delay(1720);
digitalWrite(tiltup_pin,LOW);
}
}
else{
if(digitalRead(open_pin)&&!digitalRead(close_pin)&&!closemrrlk){//Close mirror
closemrrlk=true;
digitalWrite(m1_pin,HIGH);
delay(closetmr);
digitalWrite(m1_pin,LOW);
}
if(!digitalRead(open_pin)&&digitalRead(close_pin)&&closemrrlk){//Open mirror
closemrrlk=false;
digitalWrite(m2_pin,HIGH);
delay(closetmr);
digitalWrite(m2_pin,LOW);
}
}
}
Any suggestions besides searching because I did a lot of that?