Arduino source code for Autoconnection app controller (Hyundai i30 ver)

Arduino source code for Autoconnection app controller (Hyundai i30 ver)
Please upload to arduino

//open arduino uno
//and upload below code.
//Hyundia i30 ver


//copy and paste from here
// made by joe jo

#include <TimerOne.h>
#include <avr/interrupt.h>

String data = "0";            //Variable for storing received data
int analogInput = A0;
float Vout = 0.00;
float Vin = 0.00;
float R1 = 100000.00; // resistance of R1 (100K)
float R2 = 10000.00; // resistance of R2 (10K)
int val = 0; // voltage input
int igset = 0;
String password = "0000";

boolean function1_status = false;
boolean function2_status = false;
boolean function1_check = false;
boolean function2_check = false;


//pins numbers
int doorstatus_pin = 2; //door status input pin
int door_unlock = 3;
int door_lock = 4;

int ig_acc = 5;
int ig_on = 6;
int ig_on_start = 7;
int ig_start = 8;

int function1 = 9;
int function2 = 10;

int board_led = 13;


void Wait()
{
   uint8_t i=0;
   for(;i<23;i++)
      _delay_loop_2(0);
}


void callback()
{
  val = analogRead(analogInput);//reads the analog input
   Vout = (val * 5.00) / 1024.00; // formula for calculating voltage out i.e. V+, here 5.00
   Vin = (Vout / (R2/(R1+R2)))+0.2; // formula for calculating voltage in i.e. GND
   if (Vin<0.09)//condition
   {
     Vin=0.00;//statement to quash undesired reading !
  }

Serial.print(" ");
Serial.print(Vin);
Serial.println("V");//voltage
Serial.println("\n");
Serial.println("\n");

door_status();
ig_status();
function1_stat();
function2_stat();
}


void setup()
{
    Serial.begin(9600);   //Sets the baud for serial data transmission                           
    pinMode(board_led, OUTPUT);  //Sets digital pin 13 as output pin
    //pinMode(2, INPUT);  //Sets digital pin 2 as Input pin
    pinMode(doorstatus_pin, INPUT_PULLUP); //normally input is pull down status
    //attachInterrupt(digitalPinToInterrupt(doorstatus_pin), door_status, CHANGE); //disabled this time because too sensitive and cause too much inturrubt
    pinMode(analogInput, INPUT); //assigning the input port

    pinMode(door_unlock, OUTPUT);
    pinMode(ig_acc, OUTPUT);
    pinMode(ig_on, OUTPUT);
    pinMode(ig_on_start, OUTPUT);
    pinMode(ig_start, OUTPUT);
    pinMode(door_lock, OUTPUT);
    pinMode(function1, OUTPUT);
    pinMode(function2, OUTPUT);

    digitalWrite(door_unlock, HIGH);
    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH);
    digitalWrite(ig_start, HIGH);
    digitalWrite(door_lock, HIGH);
    digitalWrite(function1, HIGH);
    digitalWrite(function2, HIGH);

 Timer1.initialize(1000000*3);         // initialize timer1, and set a 1/2 second period
  //Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt

}

void function1_stat()
{
  if (function1_status == true){Serial.println(" f1o");}
  if (function1_status == false){Serial.println(" f1f");}
}

void function2_stat()
{
  if (function2_status == true){Serial.println(" f2o");}
  if (function2_status == false){Serial.println(" f2f");}
}


void ig_status()
{
  switch (igset){
    case (0) : Serial.println(" i0");  break;
    case (1) : Serial.println(" i1");  break;
    case (2) : Serial.println(" i2"); break;
    case (3) : Serial.println(" i3");  break;
  }
}
void igup()
{
  igset = igset + 1;

    if (igset >= 3)
    {
      igset = 3;
    }

    igsetup();
}

//we call IG up
void igdown()
{
  igset = igset - 1;

    if (igset <= 0)
    {
      igset = 0;
    }
    igsetup();
}

void igsetup()
{

    switch (igset){
    case (0) : igoff_f(); break;
    case (1) : igacc_f(); break;
    case (2) : igon_f(); break;
    case (3) : igstart_f(); break;

  }
}
void igoff_f()
{igset = 0;

    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH);
    digitalWrite(ig_start, HIGH);
    digitalWrite(board_led, LOW);
    ig_status();
}

void igacc_f()
{
  igset = 1;


    digitalWrite(ig_acc, LOW);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH); 
    digitalWrite(ig_start, HIGH);
    ig_status();
}
void igon_f()
{
  igset = 2;


    digitalWrite(ig_acc, LOW);
    digitalWrite(ig_on, LOW);
    digitalWrite(ig_on_start, LOW);
    digitalWrite(ig_start, HIGH);
    ig_status();
}

void igstart_f()
{
igset = 3;
//noInterrupts();
    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, LOW);
    digitalWrite(ig_on_start, HIGH); 
    digitalWrite(ig_start, LOW);
    ig_status();
     delay(1000*3); igon_f();
          // interrupts();

}
void door_status()
{
    noInterrupts();
  // critical, time-sensitive code here

             if (digitalRead(doorstatus_pin) == HIGH)
             {Serial.println(" dl");}
             else
             {Serial.println(" du");}//only when grounded
                   interrupts();
              delay(10); //for switching effect

  // other code here     
}

void autounlock()
{

             if (digitalRead(doorstatus_pin) == HIGH)
             {Serial.println(" dl");
             digitalWrite(door_unlock, LOW);
             delay(100);
             digitalWrite(door_unlock, HIGH);
             digitalWrite(board_led, LOW);
             }
             else
             {Serial.println(" du");}//only when grounded
              delay(100); //for switching effect

}

void door_unlock_f()
{

             digitalWrite(door_unlock, LOW);
             delay(100);
             digitalWrite(door_unlock, HIGH);
             digitalWrite(board_led, LOW);

}

void door_lock_f()
{

             digitalWrite(door_lock, LOW);
             delay(100);
             digitalWrite(door_lock, HIGH);
             digitalWrite(board_led, LOW);

}

void function1_f()
{
  if (function1_status == false){ digitalWrite(function1, LOW); function1_check = true;}
  if (function1_status == true){ digitalWrite(function1, HIGH); function1_check = false;}

  if (function1_check == true){function1_status = true;}
  if (function1_check == false){function1_status = false;}
  function1_stat();
}

void function2_f()
{
  if (function2_status == false){ digitalWrite(function2, LOW); function2_check = true;}
  if (function2_status == true){ digitalWrite(function2, HIGH); function2_check = false;}

  if (function2_check == true){function2_status = true;}
  if (function2_check == false){function2_status = false;}
  function2_stat();
}


void loop()
{
     
   if(Serial.available() > 0)      // Send data only when you receive data:

   {
      data = Serial.readString();        //Read the incoming data & store into data
 
      Serial.print(data);          //Print Value inside data in Serial monitor
      Serial.print("\n");

      if(data.startsWith(password) && (data.charAt(4) == '%'))// chartAT(start from'0')   

          {
           digitalWrite(13, HIGH);   //If value is 1 then LED turns ON
          // Serial.println("matched password");
           if (data.endsWith("x") && (data.charAt(5) == '1'))
           {
            if (igset == 0){  autounlock();}     
           }
           if (data.endsWith("x") && (data.charAt(6) == '1'))
           {
            if (igset == 0){
             igset = 3;
             igsetup(); }
           
           }
           if (data.endsWith("x") && (data.charAt(7) == '1'))
           {
             if (igset == 0){ function1_f(); }       
           }
           if (data.endsWith("lockon"))
           {
             door_lock_f();
             door_status();
             ig_status();         
           }
           else if (data.endsWith("lockoff"))
           {
             door_unlock_f();
             door_status();
             ig_status(); 
           }
           else if (data.endsWith("func1"))
           {
             function1_f();
           }
           else if (data.endsWith("func2"))
           {
             function2_f();
           }
           else if (data.endsWith("status"))
           {
            door_status();
            ig_status();
           }
           else if (data.endsWith("igup"))
           {
            igup();
           }
           else if (data.endsWith("igdown"))
           {
       
            igdown();
           }
     
          }
      else if(data.startsWith(password) && (data.charAt(4) == '$'))
          {
            Serial.println(" sa");
            password[0] = data.charAt(5);
            password[1] = data.charAt(6);
            password[2] = data.charAt(7);
            password[3] = data.charAt(8);
          }

      else
      {
        Serial.println(" wr");//wrong password
         digitalWrite(13, LOW);
      }
  }


}

Arduino source code for Autoconnection app controller (toyota landcruiser/prado ver)

Arduino source code for Autoconnection app controller (toyota landcruiser/prado ver)


//open arduino uno
//and upload below code.
//toyota landcruiser/prado ver

//copy and paste from here
// made by joe jo

#include <TimerOne.h>
#include <avr/interrupt.h>

String data = "0";            //Variable for storing received data
int analogInput = A0;
float Vout = 0.00;
float Vin = 0.00;
float R1 = 100000.00; // resistance of R1 (100K)
float R2 = 10000.00; // resistance of R2 (10K)
int val = 0; // voltage input
int igset = 0;
String password = "0000";

boolean function1_status = false;
boolean function2_status = false;
boolean function1_check = false;
boolean function2_check = false;


//pins numbers
int doorstatus_pin = 2; //door status input pin
int door_unlock = 3;
int door_lock = 4;

int ig_acc = 5;
int ig_on = 6;
int ig_on_start = 7;
int ig_start = 8;

int function1 = 9;
int function2 = 10;

int board_led = 13;


void Wait()
{
   uint8_t i=0;
   for(;i<23;i++)
      _delay_loop_2(0);
}


void callback()
{
  val = analogRead(analogInput);//reads the analog input
   Vout = (val * 5.00) / 1024.00; // formula for calculating voltage out i.e. V+, here 5.00
   Vin = (Vout / (R2/(R1+R2)))+0.2; // formula for calculating voltage in i.e. GND
   if (Vin<0.09)//condition
   {
     Vin=0.00;//statement to quash undesired reading !
  }

Serial.print(" ");
Serial.print(Vin);
Serial.println("V");//voltage
Serial.println("\n");
Serial.println("\n");

door_status();
ig_status();
function1_stat();
function2_stat();
}


void setup()
{
    Serial.begin(9600);   //Sets the baud for serial data transmission                           
    pinMode(board_led, OUTPUT);  //Sets digital pin 13 as output pin
    //pinMode(2, INPUT);  //Sets digital pin 2 as Input pin
    pinMode(doorstatus_pin, INPUT_PULLUP); //normally input is pull down status
    //attachInterrupt(digitalPinToInterrupt(doorstatus_pin), door_status, CHANGE); //disabled this time because too sensitive and cause too much inturrubt
    pinMode(analogInput, INPUT); //assigning the input port

    pinMode(door_unlock, OUTPUT);
    pinMode(ig_acc, OUTPUT);
    pinMode(ig_on, OUTPUT);
    pinMode(ig_on_start, OUTPUT);
    pinMode(ig_start, OUTPUT);
    pinMode(door_lock, OUTPUT);
    pinMode(function1, OUTPUT);
    pinMode(function2, OUTPUT);

    digitalWrite(door_unlock, HIGH);
    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH);
    digitalWrite(ig_start, HIGH);
    digitalWrite(door_lock, HIGH);
    digitalWrite(function1, HIGH);
    digitalWrite(function2, HIGH);

 Timer1.initialize(1000000*3);         // initialize timer1, and set a 1/2 second period
  //Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt

}

void function1_stat()
{
  if (function1_status == true){Serial.println(" f1o");}
  if (function1_status == false){Serial.println(" f1f");}
}

void function2_stat()
{
  if (function2_status == true){Serial.println(" f2o");}
  if (function2_status == false){Serial.println(" f2f");}
}


void ig_status()
{
  switch (igset){
    case (0) : Serial.println(" i0");  break;
    case (1) : Serial.println(" i1");  break;
    case (2) : Serial.println(" i2"); break;
    case (3) : Serial.println(" i3");  break;
  }
}
void igup()
{
  igset = igset + 1;

    if (igset >= 3)
    {
      igset = 3;
    }

    igsetup();
}

//we call IG up
void igdown()
{
  igset = igset - 1;

    if (igset <= 0)
    {
      igset = 0;
    }
    igsetup();
}

void igsetup()
{

    switch (igset){
    case (0) : igoff_f(); break;
    case (1) : igacc_f(); break;
    case (2) : igon_f(); break;
    case (3) : igstart_f(); break;

  }
}
void igoff_f()
{igset = 0;

    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH);
    digitalWrite(ig_start, HIGH);
    digitalWrite(board_led, LOW);
    ig_status();
}

void igacc_f()
{
  igset = 1;


    digitalWrite(ig_acc, LOW);
    digitalWrite(ig_on, HIGH);
    digitalWrite(ig_on_start, HIGH); 
    digitalWrite(ig_start, HIGH);
    ig_status();
}
void igon_f()
{
  igset = 2;


    digitalWrite(ig_acc, LOW);
    digitalWrite(ig_on, LOW);
    digitalWrite(ig_on_start, LOW);
    digitalWrite(ig_start, HIGH);
    ig_status();
}

void igstart_f()
{
igset = 3;
//noInterrupts();
    digitalWrite(ig_acc, HIGH);
    digitalWrite(ig_on, LOW);
    digitalWrite(ig_on_start, HIGH); 
    digitalWrite(ig_start, LOW);
    ig_status();
     delay(1000*3); igon_f();
          // interrupts();

}
void door_status()
{
    noInterrupts();
  // critical, time-sensitive code here

             if (digitalRead(doorstatus_pin) == HIGH)
             {Serial.println(" dl");}
             else
             {Serial.println(" du");}//only when grounded
                   interrupts();
              delay(10); //for switching effect

  // other code here     
}

void autounlock()
{

             if (digitalRead(doorstatus_pin) == HIGH)
             {Serial.println(" dl");
             digitalWrite(door_unlock, LOW);
             delay(100);
             digitalWrite(door_unlock, HIGH);
             digitalWrite(board_led, LOW);
             }
             else
             {Serial.println(" du");}//only when grounded
              delay(100); //for switching effect

}

void door_unlock_f()
{

             digitalWrite(door_unlock, LOW);
             delay(100);
             digitalWrite(door_unlock, HIGH);
             digitalWrite(board_led, LOW);

}

void door_lock_f()
{

             digitalWrite(door_lock, LOW);
             delay(100);
             digitalWrite(door_lock, HIGH);
             digitalWrite(board_led, LOW);

}

void function1_f()
{
  if (function1_status == false){ digitalWrite(function1, LOW); function1_check = true;}
  if (function1_status == true){ digitalWrite(function1, HIGH); function1_check = false;}

  if (function1_check == true){function1_status = true;}
  if (function1_check == false){function1_status = false;}
  function1_stat();
}

void function2_f()
{
  if (function2_status == false){ digitalWrite(function2, LOW); function2_check = true;}
  if (function2_status == true){ digitalWrite(function2, HIGH); function2_check = false;}

  if (function2_check == true){function2_status = true;}
  if (function2_check == false){function2_status = false;}
  function2_stat();
}


void loop()
{
     
   if(Serial.available() > 0)      // Send data only when you receive data:

   {
      data = Serial.readString();        //Read the incoming data & store into data
 
      Serial.print(data);          //Print Value inside data in Serial monitor
      Serial.print("\n");

      if(data.startsWith(password) && (data.charAt(4) == '%'))// chartAT(start from'0')   

          {
           digitalWrite(13, HIGH);   //If value is 1 then LED turns ON
          // Serial.println("matched password");
           if (data.endsWith("x") && (data.charAt(5) == '1'))
           {
            if (igset == 0){  autounlock();}     
           }
           if (data.endsWith("x") && (data.charAt(6) == '1'))
           {
            if (igset == 0){
             igset = 3;
             igsetup(); }
           
           }
           if (data.endsWith("x") && (data.charAt(7) == '1'))
           {
             if (igset == 0){ function1_f(); }       
           }
           if (data.endsWith("lockon"))
           {
             door_lock_f();
             door_status();
             ig_status();         
           }
           else if (data.endsWith("lockoff"))
           {
             door_unlock_f();
             door_status();
             ig_status(); 
           }
           else if (data.endsWith("func1"))
           {
             function1_f();
           }
           else if (data.endsWith("func2"))
           {
             function2_f();
           }
           else if (data.endsWith("status"))
           {
            door_status();
            ig_status();
           }
           else if (data.endsWith("igup"))
           {
            igup();
           }
           else if (data.endsWith("igdown"))
           {
       
            igdown();
           }
     
          }
      else if(data.startsWith(password) && (data.charAt(4) == '$'))
          {
            Serial.println(" sa");
            password[0] = data.charAt(5);
            password[1] = data.charAt(6);
            password[2] = data.charAt(7);
            password[3] = data.charAt(8);
          }

      else
      {
        Serial.println(" wr");//wrong password
         digitalWrite(13, LOW);
      }
  }


}

constraint layout learning

 constraint layout learning is fun but sadly I couldn't find the way to fitting layouts to any size of mobile screen.  it is easy to org...