Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled Robotic Vehicle with Excavator Functions

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Robotic Vehicle with Excavator Functions

Circuit Documentation

Summary

The circuit in question is designed to control a set of four micro servos and two DC motors through an Arduino Nano microcontroller. The micro servos are controlled via PWM signals, while the DC motors are driven by an H-bridge (ponte h) that allows for direction control. A step-down buck converter is used to regulate the voltage from two 7.4V batteries to a suitable level for the microcontroller and servos. The Arduino Nano is programmed to interpret serial commands to manipulate the servos and control the motion of the motors, enabling forward, backward, left, and right movements.

Component List

Arduino Nano

Micro Servo 9G (x4)

Ponte H (H-Bridge)

Step Down Buck Converter

Motor Amarillo Motorreductor Hobby (x4)

7.4V Batteries (x2)

Wiring Details

Arduino Nano

Micro Servo 9G

Ponte H (H-Bridge)

Step Down Buck Converter

Motor Amarillo Motorreductor Hobby

7.4V Batteries

Documented Code

#include<Servo.h>

#define RightForward 2
#define RightBackward 3
#define LeftForward 4
#define LeftBackward 5 

char val;
int check = 1;

int Dmservo = 90;
int Dbservo = 0;
int Daservo = 20;
int Doservo = 140;

Servo mservo;
Servo aservo;
Servo bservo;
Servo oservo;

void setup(){
  Serial.begin(9600);

  bservo.attach(12);
  aservo.attach(11);
  mservo.attach(10);
  oservo.attach(9);

  pinMode(RightForward,OUTPUT);
  pinMode(RightBackward,OUTPUT);
  pinMode(LeftForward,OUTPUT);
  pinMode(LeftBackward,OUTPUT);

  bservo.write(Dbservo);
  aservo.write(Daservo);
  mservo.write(Dmservo);
  oservo.write(Doservo);
}

void loop(){

  if(Serial.available()){
    val = Serial.read();
    Serial.println(val);

    if(val == 'X'){
      check = 0;
    }
    if(val == 'x'){
      check = 1;
    }

    if(check == 1){
       car();
    }
    if(check == 0){
      excavator();
    }

  }

}

void excavator(){

  if(val == 'G'){
    Dbservo += 2;
    bservo.write(Dbservo);
  }
  if(val == 'I'){
    Dbservo -=2;
    bservo.write(Dbservo);
  }
  if(val == 'F'){
    Daservo +=2;
    aservo.write(Daservo);
  }

  if(val == 'B'){
    Daservo-=2;
    aservo.write(Daservo);
  }

  if(val == 'R'){
    Dmservo -=2;
    mservo.write(Dmservo);
  }

  if(val == 'L'){
    Dmservo +=2;
    mservo.write(Dmservo);
  }

  if(val == 'J'){
    Doservo +=2;
    oservo.write(Doservo);
  }
  if(val == 'H'){
    Doservo -=2;
    oservo.write(Doservo);

  }

}

void car(){

  if(val == 'F'){
    forward();
  }
  if(val == 'B'){
    backward();
  }
  if(val == 'R'){
    right();
  }
  if(val == 'L'){
    left();
  }
  if(val == 'S'){
    stop();
  }
  if(val == 'I'){
    right();
  }
  if(val == 'G'){
    left();
  }
  if(val == 'J'){
    left();
  }
  if(val == 'H'){
    right();
  }

}

void forward(){
  digitalWrite(RightForward,HIGH);
  digitalWrite(LeftForward,HIGH);

  digitalWrite(RightBackward,LOW);
  digitalWrite(LeftBackward,LOW);
}

void backward(){
  digitalWrite(RightForward,LOW);
  digitalWrite(LeftForward,LOW);

  digitalWrite(RightBackward,HIGH);
  digitalWrite(LeftBackward,HIGH); 
}

void right(){
  digitalWrite(RightForward,LOW);
  digitalWrite(LeftForward,HIGH);

  digitalWrite(RightBackward,HIGH);
  digitalWrite(LeftBackward,LOW);
}

void left(){
  digitalWrite(RightForward,HIGH);
  digitalWrite(LeftForward,LOW);

  digitalWrite(RightBackward,LOW);
  digitalWrite(LeftBackward,HIGH);
}

void stop(){
  digitalWrite(RightForward,LOW);
  digitalWrite(LeftForward,LOW);

  digitalWrite(RightBackward,LOW);
  digitalWrite(LeftBackward,LOW);
}

This code is designed to control the movement of a vehicle with two DC motors and manipulate the position of four servos. It listens for serial input and adjusts the motor direction and servo positions accordingly.