Arslan Habib
Created July 15, 2017

Robotic Car

using Arduino, FlySky FS-i6 Transmitter and receiver, Motor shield , ultrasonic sensor

529
Robotic Car

Things used in this project

Code

ROBOCAR

Arduino
#define IN1 2
#define IN2 3

////////////////  DC Motor 2  Pins

#define IN3 4
#define IN4 5

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);


}

//Main Program
void loop() {

    int sp3 = pulseIn(A4, HIGH);
    int sp4 = pulseIn(A5, HIGH);
// Serial.println(sp4);

  if(sp3> 1500)
    {
     Serial.println("FORWARD");
     
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
      
    }
    if(sp3<1400)
    {
      Serial.println("BACKWARD");
     digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
    }
     if(sp3>1400 && sp3< 1500)
    {
  Serial.println("stop");
  digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);

   
    }


    ///left right



     if(sp4< 1400)
    {
     Serial.println("Left");
      digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
    }
    if(sp4>1550)
    {
      Serial.println("RIGHT");
      digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
     
    }

    
  
  
}


   

Credits

Arslan Habib

Arslan Habib

0 projects • 0 followers

Comments