Duc Lap Phan
Published

Arduino Vehicle with Sprayer

Using Arduino Mega 2560 to control motor system and arm with an attached sprayer.

IntermediateShowcase (no instructions)12 hours1,223
Arduino Vehicle with Sprayer

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
HC-06 Bluetooth Module
HC-05 is also viable
×1
L298N Motor Drive Controller Board
×6
JGB37-520 DC Geared Motor
×4
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
MG996R Robot servo 180° Rotation
MG995 180 is also viable
×3
LM2596s Buck Converter
×1
Pump EK1856
×1
MAKERFACTORY 5V relay module compatible with Arduino
MAKERFACTORY 5V relay module compatible with Arduino
×1
Mecanum Wheels
Other type of mecanum wheels can be used
×1
18650 3.7V Panasonic Battery
Other type of batteries can used as long as they can provide 12V for the system
×3
18650 Battery Holder x3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

MIT App Inventor
MIT App Inventor

Story

Read more

Custom parts and enclosures

3D Robotic Arm

These file can be gathered from https://howtomechatronics.com/tutorials/arduino/diy-arduino-robot-arm-with-smartphone-control/ provided by Dejan, discarding the Gripper part.

Schematics

Schematic

Based from the design in Proteus

Proteus Schematic

Note that using the LM2596 Module will not need additional components such as capacitors around it. Only need to connect Input and Output normally.
The HC-06 Module must be connected from 5V Arduino Mega pin instead of from LM2596 since it can cause the Bluetooth module to stop when controlling the Servo,

Code

projectfinal.ino

Arduino
The code is based on how you program App Inventor
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
int relay = 8;
// Motor R1 connections
int inA1 = 5;
int inA2 = 4;
// Motor L1 connections
int inA3 = 6;
int inA4 = 7;
//Motor R2:
int inB1 = 15;
int inB2 = 14;
//Motor L2:
int inB3 = 16;
int inB4 = 17;

char input=0; //input to be used

void setup(){
Serial1.begin(9600);
Serial1.setTimeout(10);
//Servo pins:
servo1.attach(9);
servo2.attach(10);
servo3.attach(11);
pinMode(relay,OUTPUT);  
//Motor outputs:
pinMode(inA1, OUTPUT);
pinMode(inA2, OUTPUT);
pinMode(inA3, OUTPUT);
pinMode(inA4, OUTPUT);
pinMode(inB1, OUTPUT);
pinMode(inB2, OUTPUT);
pinMode(inB3, OUTPUT);
pinMode(inB4, OUTPUT); 
}

//Direction Control:
void foward(){
 digitalWrite(inA1,HIGH);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,HIGH);
 digitalWrite(inA4,LOW);
 digitalWrite(inB1,HIGH);
 digitalWrite(inB2,LOW); 
 digitalWrite(inB3,HIGH);
 digitalWrite(inB4,LOW);
}

void reverse(){
 digitalWrite(inA1,LOW);
 digitalWrite(inA2,HIGH); 
 digitalWrite(inA3,LOW);
 digitalWrite(inA4,HIGH);
 digitalWrite(inB1,LOW);
 digitalWrite(inB2,HIGH); 
 digitalWrite(inB3,LOW);
 digitalWrite(inB4,HIGH);
}

void hold(){
 digitalWrite(inA1,LOW);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,LOW);
 digitalWrite(inA4,LOW);
 digitalWrite(inB1,LOW);
 digitalWrite(inB2,LOW); 
 digitalWrite(inB3,LOW);
 digitalWrite(inB4,LOW);  
}

void right(){
 digitalWrite(inA1,HIGH);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,LOW);
 digitalWrite(inA4,LOW);
 digitalWrite(inB1,HIGH);
 digitalWrite(inB2,LOW); 
 digitalWrite(inB3,LOW);
 digitalWrite(inB4,LOW);
}

void left(){
 digitalWrite(inA1,LOW);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,HIGH);
 digitalWrite(inA4,LOW);
 digitalWrite(inB1,LOW);
 digitalWrite(inB2,LOW); 
 digitalWrite(inB3,HIGH);
 digitalWrite(inB4,LOW);
}

void spin(){
 digitalWrite(inA1,HIGH);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,LOW);
 digitalWrite(inA4,HIGH);
 digitalWrite(inB1,LOW);
 digitalWrite(inB2,HIGH); 
 digitalWrite(inB3,HIGH);
 digitalWrite(inB4,LOW);  
}

void sideR(){
 digitalWrite(inA1,LOW);
 digitalWrite(inA2,HIGH); 
 digitalWrite(inA3,HIGH);
 digitalWrite(inA4,LOW);
 digitalWrite(inB1,LOW);
 digitalWrite(inB2,HIGH); 
 digitalWrite(inB3,HIGH);
 digitalWrite(inB4,LOW);  
}


void sideL(){
 digitalWrite(inA1,HIGH);
 digitalWrite(inA2,LOW); 
 digitalWrite(inA3,LOW);
 digitalWrite(inA4,HIGH);
 digitalWrite(inB1,HIGH);
 digitalWrite(inB2,LOW); 
 digitalWrite(inB3,LOW);
 digitalWrite(inB4,HIGH);  
}

void loop(){
if (Serial1.available() > 0) {

//c d liu gi v
input = Serial1.read();
} 

//Motor Controlling:
if(input == 1){
input = Serial1.read();  
foward();
}

else if(input == 2){
input = Serial1.read();
reverse();
}

else if (input == 3){
input = Serial1.read();
left();
}

else if (input == 4){
input = Serial1.read();  
right();
}

else if (input == 5){
spin();
}

else if (input == 6){
input = Serial1.read();  
sideL();
}

else if (input == 7){
input = Serial1.read();  
sideR();
}

else if (input == 0){ 
input = Serial1.read();  
hold();
}

//Servo Controlling:

//Arm:
  if(input==8)
  {
  input = Serial1.read(); 
  servo2.write(150);
  }
    if(input==9)
  {
   input = Serial1.read(); 
  servo2.write(180);
  }

 //Gripper:
    if(input==10)
  {
   input = Serial1.read();  
  servo1.write(50);
  }
    if(input==11)
  {
   input = Serial1.read(); 
  servo1.write(100);
  }
    if(input==12)
  {
   input = Serial1.read(); 
  servo1.write(150);          
  }

//Base:
    if(input==13)
  {
   input = Serial1.read(); 
  servo3.write(180);          
  }

    if(input==14)
  {
   input = Serial1.read(); 
  servo3.write(130);          
  }

    if(input==15)
  {
  input = Serial1.read(); 
  servo3.write(80);          
  }

//Relay:
     if(input==16)
 {
  input = Serial1.read(); 
digitalWrite(relay,HIGH);        
 } 

      if(input==17)
 {
  input = Serial1.read(); 
digitalWrite(relay,LOW);        
 } 

delay(10);
}

BEM_Final.aia

Java
This is a file opened by using App Inventor
No preview (download only).

Credits

Duc Lap Phan
1 project • 0 followers
Studying Electrical Engineering at HCMUTE
Contact
Thanks to Dejan.

Comments

Please log in or sign up to comment.