Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
SetNFix
Published © GPL3+

One Touch Auto Roll Up Window Module DIY

Universal car auto roll-up window unit

AdvancedFull instructions provided8,249
One Touch Auto Roll Up Window Module DIY

Things used in this project

Hardware components

Resistor 1k ohm
Resistor 1k ohm
×1
Through Hole Resistor, 120 ohm
Through Hole Resistor, 120 ohm
×1
Signal Relay, 5 VDC
Signal Relay, 5 VDC
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
5 mm LED: Red
5 mm LED: Red
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
General Purpose Transistor PNP
General Purpose Transistor PNP
×1
Optocoupler, Transistor Output
Optocoupler, Transistor Output
×1
ATmega328
Microchip ATmega328
×1
Capacitor 22 pF
Capacitor 22 pF
×1
16 MHz Crystal
16 MHz Crystal
×1
Ceramic Disc Capacitor, 0.1 µF
Ceramic Disc Capacitor, 0.1 µF
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Capacitor 100 µF
Capacitor 100 µF
×1
1N5819 – 1A Schottky Barrier Rectifier
1N5819 – 1A Schottky Barrier Rectifier
×1
SparkFun Low Current Sensor Breakout - ACS712
SparkFun Low Current Sensor Breakout - ACS712
×1
Arduino 101
Arduino 101
×1

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Schematics

Plan

Code

Full code

Arduino
Upload with Arduino software
 
        /*PROGRAMME : CAR WINDOW AUTO RALL UP
PROGRAMMED BY : SetNfix
WEBSITE : HTTP://WWW.SetNfix.COM
Ownner : BMIAK Basnayaka
******************************************************************
THIS PROGRAMME IS FOR THE VEHICLES WITH FOLLOWING SETTINGS
1.CAR DOOR LIGHT ON/OFF BY NEGATIVE 
2.CAR HORN NEGATIVE
3.POWER WINDOW SYSTEM
AUTO RALL UP WILL WORK WHEN
1.THE CAR IS OFF, THE DOORS ARE CLOSED THEN SECURITY KEY PRESS LOCK, THE FRONT
TWO WINDOWS WILL BE SHUT AUTOMATICALLY.
2.THE CAR IS STARTED AND IF THE AUTO SWITCH ON, IF YOU PRESS WINDOW UP
ONCE THE DRIVER SIDE WINDOW WILL GO UP AUTOMATICALLY*/

int UpSwitch = 0;
int DwnSwitch = 0;
int UpSwitch_Pin = 11;
int DwnSwitch_Pin = 12;

int RMotorUp = 0;
int RMotorDwn = 0;
int LMotorUp = 0;
int RMotorUp_Pin = 10;
int RMotorDwn_Pin = 9;
int LMotorUp_Pin = 8;


int CarDoor =0;
int Sensor = 0;
int Acc = 0;
int Btt = 0;
int CarDoor_Pin =7;
int Acc_Pin = 6;
int Sensor_Pin = 5;

int Btt_Pin = 4; 

int CarHorn=0;
int Reset = 0;
int Reset_Pin = 3;
int CarHorn_Pin=A0; // To car horn


int LED = 13;

int DataUpR = 0;
int DataDwnR = 0;
int DataUpL = 0;
int DataUpR_Pin = A1; // To control the unit using external commands
//int DataDwnR_Pin = A1;
//int DataUpL_Pin = A2;

int Active = 0;
int Cancel = 0;
int Window = 0; //
int Interrupt = 0;
float OldMillis;
float NewMillis;
float Balancemillis;
int Timmer = 6000; // Average time to close/Open a window (6s)

int x = 0; //if the door is locked by key, value will be  = 1.
int y;

long a = 0;// time push and hold the button.
int aUp = 0;// window up pressed
int aDwn = 0;//window down pressed
int Clicked = 0;// button was pressed when =1

//Current sensor Unit
int CrntPin = A2;
float Anval = 0.0;
float Vlt = 0.0;
float Dflt = 66; // Default value of 30A current sensor
float Amps = 0.0;
int Svolt = 2500; // Default voltage of the sensor 2.5v
int Limit = 6; // This is by amps (10 A)
int limiton = 7 ; //limit for normal operation
int Motor = 0;
int ux = 0;
int uy = 0;


//Roll uo timing

int upx = 0;
int upy = 0;



void setup() {
  Serial.begin(9600);
 
pinMode(UpSwitch_Pin,INPUT);
pinMode(DwnSwitch_Pin,INPUT);
pinMode(RMotorUp_Pin,OUTPUT);
pinMode(RMotorDwn_Pin,OUTPUT);
pinMode(LMotorUp_Pin,OUTPUT);
pinMode(CarDoor_Pin,INPUT);
pinMode(Sensor_Pin,INPUT);
pinMode(Acc_Pin,INPUT);
pinMode(Btt_Pin,INPUT);
pinMode(CarHorn_Pin,OUTPUT);
pinMode(Reset_Pin,OUTPUT);
pinMode(DataUpR_Pin,INPUT);
pinMode(CrntPin,INPUT);
pinMode(LED,OUTPUT);
 //****************************************************************
CarDoor =digitalRead(CarDoor_Pin);
Sensor=digitalRead(Sensor_Pin);
Acc =digitalRead(Acc_Pin);
Btt =digitalRead(Btt_Pin);



//-------------------------------------------------------------------
//------------CHECK THAT THE CAR LOCKED BY REMOTE KEY OR DOOR--------
//-------------------------------------------------------------------
/* IF THE CAR IS LOCKED BY REMOTE KEY, THEN SECURITY LED START TO BLINK
 *  BUT IT IS LOCKED BY DOOR LOCK, NOTHING LIGHT
 */

int cnt = 1;

do{
  Sensor = digitalRead(Sensor_Pin);
  digitalWrite(LED,HIGH);
  delay(30);
  cnt = cnt +1;
  if (Sensor ==1){x = 1;cnt = 120;Serial.print("KEY LOCKED");}
  digitalWrite(LED,LOW);
}while (cnt < 100);

//------------------------------------------------------------------
// If the door is locked by door, reset the unit
//------------------------------------------------------------------
if (x == 0){//If the door is locked not by remote key
digitalWrite(Reset_Pin,HIGH); // Activate Reset relay
delay(500);
digitalWrite(Reset_Pin,LOW);
}//-----------------------------------------------------------------

 
//****************************************************************
//================CAR LOCK Shutter
//****************************************************************
if ((Acc ==0)&&(CarDoor ==1)&&(Btt==1)&&(x==1)){ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Serial.println("Key lock Shutter 01");
   digitalWrite(LED,HIGH);
  delay(1000); 
carhorn();
delay(2000);
 digitalWrite(LED,LOW);
 
do {
CurrentSensor();  
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(RMotorUp_Pin,HIGH); // roll up window
Serial.print("UPR : ");
Serial.println(upx);
Serial.print("MOTOR : ");
Serial.println(Motor);

digitalWrite(LED,LOW);
delay(100);
upx++;
if ((Motor == 0)&&(upy < 35)){ux = 0;} else { ux = 1;}
}while(ux ==0);
digitalWrite(RMotorUp_Pin,LOW); // roll up window STOP!
Serial.println("STEP  1");
delay(500);
CurrentSensor(); 
delay(50);

do {
CurrentSensor();  
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LMotorUp_Pin,HIGH);
Serial.print("UPY : ");
Serial.println(upy);
Serial.print("MOTOR : ");
Serial.println(Motor);
digitalWrite(LED,LOW);
delay(100);
upy++;

if ((Motor == 0)&&(upy < 35)){uy = 0;} else { uy = 1;}

}while(uy == 0);
digitalWrite(LMotorUp_Pin,LOW);
delay(500);
CurrentSensor(); 
delay(50);
//----------------------------------------------------------------
digitalWrite(Reset_Pin,HIGH);
delay(500);
digitalWrite(Reset_Pin,LOW);

}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
} //************** END VOID SETUP************************



void loop() {

UpSwitch = digitalRead(UpSwitch_Pin);
DwnSwitch = digitalRead(DwnSwitch_Pin);
CarDoor =digitalRead(CarDoor_Pin);
Sensor=digitalRead(Sensor_Pin);
Acc =digitalRead(Acc_Pin);
Btt =digitalRead(Btt_Pin);


CurrentSensor(); // GEt current sensor value
delay(50);

//-------------------------------------------------------
//Reset if key lock inside the car when engine is started
//-------------------------------------------------------
if ((Acc==1)&&(Btt==1)){
  Serial.println("key lock inside the car when engine is started");
  digitalWrite(Reset_Pin,HIGH);
  delay(500);
  digitalWrite(Reset_Pin,LOW);
}
//-------------------------------------------------------




//Inturrupted to the current process
if ((Active == 1)&&(Interrupt == 0)){
if (digitalRead(UpSwitch_Pin)==1){Window = 1;Interrupt=1;Serial.print("UpSwitch : ");
Serial.println(digitalRead(UpSwitch_Pin));}

if (digitalRead(DwnSwitch_Pin)==1){Window = 2;Interrupt=1;Serial.print("DwnSwitch : ");
Serial.println(digitalRead(DwnSwitch_Pin));}


}
//Stop When Interrupt
if (Interrupt == 1){digitalWrite(RMotorUp_Pin,LOW); digitalWrite(RMotorDwn_Pin,LOW);Serial.println("STEP  05");Window = 0;Active =0; Balancemillis=0; OldMillis = 0;LedBlink();Serial.println("Interrupted");delay(2000);Interrupt =0;}

/*/testing----------------------------
if ((UpSwitch ==1)||(DwnSwitch ==1)){
 if (UpSwitch ==1){aUp = 1; aDwn =0;}
 if (DwnSwitch ==1){aUp = 0; aDwn =1;} 
 Clicked = 1; //BUTTON PRESSED
  delay(10);
  a = a + 1;
}

//FIND THE DURATION TO RELEASE THE BUTTON
if (Clicked ==1){
  delay(10);
  a = a + 1;
  
}*/






//-----------------------------------------
//Auto Up the window
if ((UpSwitch ==1)||(DwnSwitch ==1)){
  delay(200);
  Serial.print("TOUCHED");
if ((Active == 0)&&(Interrupt == 0)){
if ((UpSwitch ==1)&&(digitalRead(UpSwitch_Pin)==0)){Window = 1;Active=1; OldMillis = millis();}
if ((DwnSwitch ==1)&&(digitalRead(DwnSwitch_Pin)==0)){Window = 2;Active=1;OldMillis = millis();}
}
Serial.println(Window);
}

//-----------------------------------------

//***********************************************************
//WINDOW RALL UP
//***********************************************************
if ((Window == 1)&&(Active==1)&&(Interrupt == 0)&&(BalancemillisTimmer)||(Amps >limiton)){
   digitalWrite(RMotorUp_Pin,LOW);
   digitalWrite(RMotorDwn_Pin,LOW);
   Serial.println("STEP  01");
   digitalWrite(LED,LOW);
Active=0; Balancemillis=0; OldMillis = 0;Window = 0;Interrupt =0;Serial.println("WINDOW STOP");delay(500);}
}
//------------------------------------------------------------


//---------------------------------------------------------------
// External Conrol wire
//---------------------------------------------------------------
DataUpR = analogRead(DataUpR_Pin);
Serial.print("DataUpR : ");
Serial.println(DataUpR);
if ((DataUpR>200)&&(DataUpR400)&&(DataUpR300)&&(DataUpR200)&&(DataUpR Limit){Motor = 1;} else {Motor = 0;} // value "0" is motor is rotating and "1" is blocked.
Serial.print("AMPS : ");
Serial.println(Amps);

//**************************************************************************************
}

Credits

SetNFix
17 projects • 35 followers
I am an accountant in profession but, I would more prefer to work with electronics based innovations.
Contact

Comments

Please log in or sign up to comment.