Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Neeraj pokalaSuresh Krishna
Published

Agricultural Pesticide Spraying Robot

This project can assist individuals in a variety of situations including agricultural production and pesticide application.

IntermediateFull instructions provided6,733
Agricultural Pesticide Spraying Robot

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DC Motor, 12 V
DC Motor, 12 V
×4
9V battery (generic)
9V battery (generic)
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Maker Essentials - Micro-motors & Grippy Wheels
Pimoroni Maker Essentials - Micro-motors & Grippy Wheels
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
DC/DC Charge Pump Adjustable Voltage Regulator, 2.7V to 5.5V in
DC/DC Charge Pump Adjustable Voltage Regulator, 2.7V to 5.5V in
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Web Editor
Arduino Web Editor
MIT App Inventor 2
MIT App Inventor 2

Story

Read more

Schematics

Block Diagram

Code

Arduino code pesticide spraying robot

C#
#include <Servo.h>
#include <SoftwareSerial.h>
SoftwareSerial BT(A0, A1);

Servo servo_1;
Servo servo_2;

int motor_r2 = 6;
int motor_r1 = 7;

int motor_l2 = 8;
int motor_l1 = 9;

int state;
int speed = 130;

int pos1 = 90;
int pos2 = 90;

int pump = 4;
int pwm = 5;

void setup(){
servo_1.attach(2);
servo_2.attach(3);
servo_1.write(pos1); 
servo_2.write(pos2); 

pinMode(motor_l1, OUTPUT);
pinMode(motor_l2, OUTPUT); 
pinMode(motor_r1, OUTPUT);
pinMode(motor_r2, OUTPUT);

pinMode(pump, OUTPUT);

pinMode(pwm, OUTPUT);

// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
BT.begin(9600); // Setting the baud rate of Software Serial Library 
 
 delay(1000);
 }

void loop(){
//if some date is sent, reads it and saves in state
if(BT.available() > 0){     
state = BT.read(); 
Serial.println(state);
if(state > 15){speed = state;}      
}
  
   // if the state is '1' the DC motor will go forward
     if (state == 1){forword();Serial.println("Forward!");}

// if the state is '2' the motor will Backword
else if (state == 2){backword();Serial.println("Backword!");}
    
// if the state is '3' the motor will turn left
else if (state == 3){turnLeft();Serial.println("Turn LEFT");}
    
// if the state is '4' the motor will turn right
else if (state == 4){turnRight();Serial.println("Turn RIGHT");}
    
// if the state is '5' the motor will Stop
else if (state == 5) {stop();Serial.println("STOP!");}    

else if (state == 6) {Serial.println("lift"); if(pos1<180){pos1 = pos1+1;}} 
else if (state == 7) {Serial.println("right"); if(pos1>0){pos1 = pos1-1;}} 
else if (state == 8) {Serial.println("up"); if(pos2>0){pos2 = pos2-1;}}  
else if (state == 9) {Serial.println("down"); if(pos2<180){pos2 = pos2+1;}} 

else if (state == 10){Serial.println("pump on");digitalWrite(pump, HIGH);} 
else if (state == 11){Serial.println("pump off");digitalWrite(pump, LOW);} 

servo_1.write(pos1); 
servo_2.write(pos2); 

analogWrite(pwm, speed);
delay(30);
}


void stop(){
    digitalWrite(motor_l1, LOW);
    digitalWrite(motor_l2, LOW); 
    digitalWrite(motor_r1, LOW);
    digitalWrite(motor_r2, LOW);
}

void forword(){
    digitalWrite(motor_l1, LOW);
    digitalWrite(motor_l2, HIGH); 
    digitalWrite(motor_r1, HIGH);
    digitalWrite(motor_r2, LOW);  
}

void backword(){
    digitalWrite(motor_l1, HIGH);
    digitalWrite(motor_l2, LOW); 
    digitalWrite(motor_r1, LOW);
    digitalWrite(motor_r2, HIGH);   
}


void turnRight(){
    digitalWrite(motor_l1, LOW);
    digitalWrite(motor_l2, HIGH); 
    digitalWrite(motor_r1, LOW);
    digitalWrite(motor_r2, HIGH);  
}

void turnLeft(){
    digitalWrite(motor_l1, HIGH);
    digitalWrite(motor_l2, LOW); 
    digitalWrite(motor_r1, HIGH);
    digitalWrite(motor_r2, LOW); 
}

Credits

Neeraj pokala

Neeraj pokala

1 project • 4 followers
Suresh Krishna

Suresh Krishna

3 projects • 2 followers

Comments