AGRO-BOT

Resource center for robot and how we made it

3d model

materials used

Arduino NANO/UNO * 2
DC motors 6V * 4
Motor driver H-Bridge * 1 ( L293D * 1/l298N )
Servo Motor MG996R*3
Bread Board small one * 1
Jumper cables As needed
3.7V battry 6
Battery Holder 2
BLUETOOTH MODULE (HC-05) *1
Water Pump with pipe *1

presentation slide

virtual circuit

Image G​​​allery

code

Code 1

#include // Include Servo Library.
int in1 = 7; // L298N PINS
int in2 = 8;
int in3 = 9;
int in4 = 10;
int enA = 5; // L298N SPEED CONTROL ENABLE
int enB = 6;



//CODE THAT WILL RUN ONCE
void setup()
{
//L298N PIN AS OUTPUT
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);


Serial.begin(9600); //SERIAL BEGIN FOR BLUETOOTH
}

void loop()
{
if (Serial.available()) //IF BLUETOOTH AVILABLE
BLUETOOTH(); //GO TO BLUETOOTH FUNCTION
}


void forward() //GO FORWRD FUNCTION
{
analogWrite(enA, 170); //speed is higher the enA & enB value (0-255)
analogWrite(enB, 170);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}

void backward() //GO BACKWARD FUNCTION
{
analogWrite(enA, 170); //speed is higher the enA & enB value (0-255)
analogWrite(enB, 170);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void turn_right() //TURN RIGHT FUNCTION
{
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}

void turn_left() //TURN LEFT FUNCTION
{
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void st() //STOP FUNCTION
{
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
void BLUETOOTH() //BLUETOOTH FUNCTION
{
// YOUR DEFAULTS
char data = Serial.read(); //VARIABLE VALUE IS SERIAL VALUE
Serial.println(data); //PRINT SERIAL VALUE
if (data == 'B') //IF SERIAL VALUE IS "F" CALL FORWARD FUNCTION
{
forward();
Serial.println("BLUETOOTH MODE"); //PRINT BLUETOOTH MODE IN SERIAL MONITOR
}

else if (data == 'F') //IF SERIAL VALUE IS "B" CALL BACKWARD FUNCTION
{
backward();
Serial.println("BLUETOOTH MODE");
}

else if (data == 'L') //IF SERIAL VALUE IS "L" CALL TURN LEFT FUNCTION
{
9turn_left();
}

else if (data == 'R') //IF SERIAL VALUE IS "R" CALL TURN RIGHT FUNCTION
{
turn_right();
Serial.println("BLUETOOTH MODE");
}

else if (data == 'S') //IF SERIAL VALUE IS "S" CALL STOP FUNCTION
{
st();
Serial.println("BLUETOOTH MODE");
}
}


Code 2

#include // include servo library to use its related functions
#define Servo_PWM 6 // A descriptive name for D6 pin of Arduino to provide PWM signal
Servo MG995_Servo; // Define an instance of of Servo with the name of "MG995_Servo"



void setup() {
MG995_Servo.attach(Servo_PWM); // Connect D6 of Arduino with PWM signal pin of servo motor


}


void loop() {
delay(3000);
MG995_Servo.write(90);
delay(3000);
MG995_Servo.write(180);
delay(3000);
MG995_Servo.write(270);
delay(3000);
MG995_Servo.write(360);
delay(3000);
MG995_Servo.attach(Servo_PWM);
}

text to developer

click here to Chat