Build a 4-in-1 DIY
Agriculture Rover Robot!
One robot that sows seeds 🌱, pulls weeds 🌿, sprays water 💧, and spreads fertilizer 🟣 — all by itself! Perfect for young engineers and future farmers.
Have you ever visited a farm and seen farmers toiling under the hot sun — planting seeds, pulling out weeds, and spraying crops row by row? Imagine if a little robot could do ALL of that for them! That's exactly what agricultural robots are doing in smart farms around the world today.
In this project, you'll build your very own 4-in-1 Agriculture Rover using an Arduino Mega. One robot, four superpowers: sowing seeds, pulling weeds, spraying water or pesticide, and spreading fertilizer. You switch between modes with a push of a button — and the rover gets to work!
⚡How Does the Agriculture Rover Work?
Think of our rover like a tiny robotic farmer with four different "hats" it can wear. You press a button to choose the mode, and the rover rolls through the field doing that job. Here's what each mode does:
A servo motor opens a tiny seed hopper. As the rover drives forward, seeds drop into the soil one by one — like a tiny slot machine for plants!
A rotating servo-powered claw digs a little into the soil, dislodging weed roots so they can be swept away. No more hand-pulling!
A mini water pump fills a tube to a nozzle at the front. Mist goes on! The soil moisture sensor can even detect dry patches and trigger spraying automatically.
A separate hopper servo opens to release granular fertilizer as the rover moves — spreading nutrients evenly across the crop rows.
🧰Parts You'll Need
🔌Circuit Diagram
This map shows how all the modules connect to the Arduino Mega. Follow the wire colours when building — it makes debugging so much easier!
🔗Complete Wiring Guide
Use this table to connect every wire. Match the colors to the legend above — always double-check before powering on!
🔵 L298N Motor Driver #1 (Front-Left + Back-Left wheels)
| L298N #1 Pin | Arduino Mega Pin | Wire Color |
|---|---|---|
| ENA | D2 (PWM) | YELLOW |
| IN1 | D22 | BLUE |
| IN2 | D23 | GREEN |
| ENB | D3 (PWM) | YELLOW |
| IN3 | D24 | BLUE |
| IN4 | D25 | GREEN |
| 12V | Battery + | RED |
| GND | GND | BLACK |
🔵 L298N Motor Driver #2 (Front-Right + Back-Right wheels)
| L298N #2 Pin | Arduino Mega Pin | Wire Color |
|---|---|---|
| ENA | D4 (PWM) | YELLOW |
| IN1 | D26 | BLUE |
| IN2 | D27 | GREEN |
| ENB | D5 (PWM) | YELLOW |
| IN3 | D28 | BLUE |
| IN4 | D29 | GREEN |
| 12V | Battery + | RED |
| GND | GND | BLACK |
🦾 Servos, Pump, Sensor & Display
| Module | Pin / Signal | Arduino Mega Pin | Wire |
|---|---|---|---|
| Servo 1 – Seed Hopper | Signal | D6 | ORANGE |
| Servo 2 – Weed Claw | Signal | D7 | ORANGE |
| Servo 3 – Fertilizer Gate | Signal | D8 | ORANGE |
| All Servos | VCC | 5V | RED |
| All Servos | GND | GND | BLACK |
| Mini Water Pump (via relay) | Relay IN | D9 | BLUE |
| Soil Moisture Sensor | Analog OUT | A0 | PURPLE |
| LCD I2C – SDA | SDA | D20 (SDA) | YELLOW |
| LCD I2C – SCL | SCL | D21 (SCL) | WHITE |
| Mode Button – Sow | Digital | D30 | GREEN |
| Mode Button – Weed | Digital | D31 | ORANGE |
| Mode Button – Spray | Digital | D32 | BLUE |
| Mode Button – Fertilize | Digital | D33 | PURPLE |
| Buzzer | Signal | D10 | ORANGE |
| LED – Sow (Green) | Anode (+ 220Ω) | D34 | GREEN |
| LED – Weed (Red) | Anode (+ 220Ω) | D35 | RED |
| LED – Spray (Blue) | Anode (+ 220Ω) | D36 | BLUE |
| LED – Fert (Purple) | Anode (+ 220Ω) | D37 | PURPLE |
🔧Step-by-Step Build Instructions
Assemble the 4WD Chassis
Bolt the four DC gear motors into the chassis brackets. The two motors on the left side will be called "Left" and the two on the right "Right." Attach all four wheels and check they spin freely. Mount standoffs between the two acrylic decks — the bottom deck holds motors and battery, the top deck holds the Arduino and sensors.
Mount the Motor Drivers
Screw both L298N boards to the top deck on opposite sides. Connect the Left motor pair's red and black wires to L298N #1 OUTPUT terminals, and the Right motor pair to L298N #2 outputs. Plug the 12V battery+ into both L298N's VIN terminals (you can share one GND rail on the breadboard).
Build the Seed Hopper
Take a small plastic cup or bottle cap and cut a tiny hole at the bottom (the "seed gate"). Glue Servo 1 to the side wall of the cup so its arm covers and uncovers the hole. When you send servo to 0°, the gate closes; at 90°, it opens and seeds drop. Hot-glue the hopper to the front-right corner of the top deck.
Attach the Weed Claw
Servo 2 goes on the underside of the front bumper rail (or a small bracket that extends forward). Glue 3–4 bent wire prongs to the servo arm — these are the "weed fingers." When the servo sweeps from 0° to 90° repeatedly, the claw scrapes across the top layer of soil, dislodging weeds.
Set Up the Spray System
Place the mini pump in a small water reservoir (a sealed plastic box or lunchbox works). Run the output tube along the chassis to a tiny plastic nozzle at the front of the rover. Secure the tube with cable clips or zip ties. Connect the pump to the relay module's NO and COM terminals — the relay is wired to Arduino pin D9.
Build the Fertilizer Hopper
Similar to the seed hopper — use another small container with a gate controlled by Servo 3 (pin D8). Mount it on the back-left corner of the top deck so fertilizer drops near the rear wheels and gets pressed into the soil as the rover moves forward.
Mount the Arduino Mega + Accessories
Velcro or screw the Arduino Mega to the centre of the top deck. Place the breadboard beside it. Mount the LCD on the front edge so you can read the mode display easily. Push the four mode buttons through small holes in the top deck (or mount on a separate control panel board). Stick the LEDs in a row next to the buttons.
Insert the Soil Moisture Sensor
The soil sensor has two metal prongs — these poke into the ground while the rover moves. Mount it at the very front-bottom of the chassis using a small bracket so the prongs face downward. Route its three wires (VCC, GND, A0) up to the breadboard on the top deck.
Wire Everything Using the Pin Table
Follow the wiring table in the section above wire by wire. Use the color-coded system to keep things organised. Once all wires are connected, do one final check before connecting the battery — make sure no bare wires are touching each other.
💻The Arduino Code
Install these libraries first via Sketch → Include Library → Manage Libraries: Servo (built-in), LiquidCrystal_I2C.
// ==================================================== // 🌾 DIY Agriculture Rover — Arduino Mega 2560 // Modes: SOWING · WEEDING · SPRAYING · FERTILIZING // Robo Farm Labs — Kid-Friendly Commented Version // ==================================================== #include <Servo.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> // ----- LCD ----- LiquidCrystal_I2C lcd(0x27, 16, 2); // ----- Servos ----- Servo servoSeed; // Controls seed hopper gate Servo servoWeed; // Controls weed-digging claw Servo servoFert; // Controls fertilizer gate // ----- Motor Driver Pins (L298N #1 — Left wheels) ----- const int ENA = 2, IN1 = 22, IN2 = 23; const int ENB = 3, IN3 = 24, IN4 = 25; // ----- Motor Driver Pins (L298N #2 — Right wheels) ----- const int ENC = 4, IN5 = 26, IN6 = 27; const int END = 5, IN7 = 28, IN8 = 29; // ----- Module Pins ----- const int PUMP_RELAY = 9; // Relay for water pump const int SOIL_PIN = A0; // Soil moisture analog input const int BUZZER = 10; // ----- Mode Buttons ----- const int BTN_SOW = 30; const int BTN_WEED = 31; const int BTN_SPRAY = 32; const int BTN_FERT = 33; // ----- Mode LEDs ----- const int LED_SOW = 34; const int LED_WEED = 35; const int LED_SPRAY = 36; const int LED_FERT = 37; // ----- State ----- int currentMode = 0; // 0=IDLE 1=SOW 2=WEED 3=SPRAY 4=FERT int DRIVE_SPEED = 150; // 0–255 (PWM speed) int SOIL_DRY_VAL = 600; // Analog threshold: dry soil unsigned long seedTimer = 0; bool seedOpen = false; // ===================== SETUP ===================== void setup() { // Motor pins int motorPins[] = {IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8}; for(int i=0; i<8; i++) pinMode(motorPins[i], OUTPUT); pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT); pinMode(ENC, OUTPUT); pinMode(END, OUTPUT); // Module pins pinMode(PUMP_RELAY, OUTPUT); digitalWrite(PUMP_RELAY, LOW); // pump OFF at start pinMode(BUZZER, OUTPUT); // Button pins (INPUT_PULLUP = no external resistor needed) pinMode(BTN_SOW, INPUT_PULLUP); pinMode(BTN_WEED, INPUT_PULLUP); pinMode(BTN_SPRAY, INPUT_PULLUP); pinMode(BTN_FERT, INPUT_PULLUP); // LED pins pinMode(LED_SOW, OUTPUT); pinMode(LED_WEED, OUTPUT); pinMode(LED_SPRAY, OUTPUT); pinMode(LED_FERT, OUTPUT); // Servos servoSeed.attach(6); servoWeed.attach(7); servoFert.attach(8); servoSeed.write(0); // close seed gate servoWeed.write(0); // claw retracted servoFert.write(0); // close fert gate // LCD lcd.init(); lcd.backlight(); showLCD(" AGRI ROVER ", " Press a button!"); // Start-up beep tone(BUZZER, 880, 100); delay(150); tone(BUZZER, 1100, 150); delay(300); } // ===================== LOOP ===================== void loop() { checkButtons(); // Did the user press a mode button? switch (currentMode) { case 1: modeSow(); break; case 2: modeWeed(); break; case 3: modeSpray(); break; case 4: modeFertilize(); break; default: stopAll(); break; } } // ============= BUTTON READING ============= void checkButtons() { if (digitalRead(BTN_SOW) == LOW) { setMode(1); delay(300); } if (digitalRead(BTN_WEED) == LOW) { setMode(2); delay(300); } if (digitalRead(BTN_SPRAY) == LOW) { setMode(3); delay(300); } if (digitalRead(BTN_FERT) == LOW) { setMode(4); delay(300); } } void setMode(int m) { stopAll(); currentMode = m; updateLEDs(m); tone(BUZZER, 1200, 120); String names[] = {"","SOWING","WEEDING","SPRAYING","FERTILIZE"}; showLCD("MODE SELECTED:", names[m]); delay(800); } // ============= MODE 1: SOWING ============= void modeSow() { driveForward(120); // drive slowly while sowing showLCD("MODE: SOWING", "Seeds dropping!"); // Open seed gate every 800ms (1 seed drop per step) if (millis() - seedTimer > 800) { seedTimer = millis(); seedOpen = !seedOpen; servoSeed.write(seedOpen ? 90 : 0); } } // ============= MODE 2: WEEDING ============= void modeWeed() { driveForward(100); showLCD("MODE: WEEDING", "Claws out!"); // Sweep weed claw back and forth servoWeed.write(0); delay(300); servoWeed.write(80); delay(300); } // ============= MODE 3: SPRAYING ============= void modeSpray() { int soilVal = analogRead(SOIL_PIN); driveForward(130); if (soilVal > SOIL_DRY_VAL) { // Soil is DRY — turn pump on! digitalWrite(PUMP_RELAY, HIGH); showLCD("SPRAY: DRY SOIL", "Pump ON! 💧"); } else { // Soil is wet enough — skip this patch digitalWrite(PUMP_RELAY, LOW); showLCD("SPRAY: SOIL OK", "Pump OFF ✓"); } } // ============= MODE 4: FERTILIZING ============= void modeFertilize() { driveForward(110); showLCD("MODE: FERTILIZE", "Nutrients out!"); // Open fertilizer gate continuously while in this mode servoFert.write(70); } // ============= MOTOR HELPERS ============= void driveForward(int speed) { // Left motors forward analogWrite(ENA, speed); analogWrite(ENB, speed); digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); // Right motors forward analogWrite(ENC, speed); analogWrite(END, speed); digitalWrite(IN5, HIGH); digitalWrite(IN6, LOW); digitalWrite(IN7, HIGH); digitalWrite(IN8, LOW); } void stopAll() { // Stop motors digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); digitalWrite(IN5,LOW); digitalWrite(IN6,LOW); digitalWrite(IN7,LOW); digitalWrite(IN8,LOW); // Close all attachments servoSeed.write(0); servoWeed.write(0); servoFert.write(0); digitalWrite(PUMP_RELAY, LOW); } // ============= DISPLAY HELPERS ============= void showLCD(String line1, String line2) { lcd.clear(); lcd.setCursor(0, 0); lcd.print(line1); lcd.setCursor(0, 1); lcd.print(line2); } void updateLEDs(int m) { digitalWrite(LED_SOW, m == 1); digitalWrite(LED_WEED, m == 2); digitalWrite(LED_SPRAY, m == 3); digitalWrite(LED_FERT, m == 4); }
loop() function does two things every millisecond: checks if you pressed a button (to switch mode), then runs the matching mode function. The moisture sensor reading in SPRAY mode is the coolest part — it's like giving the rover a nose to smell dry soil!✅Testing Your Rover
Motor Direction Test
Before attaching the modules, call driveForward(150) directly in setup and check all four wheels spin in the SAME forward direction. If one spins backwards, swap that motor's two wires on the L298N OUTPUT terminal.
Servo Range Test
Upload a small test sketch that sweeps each servo from 0° to 90°. Confirm the seed gate opens/closes and the weed claw digs and retracts properly. Adjust the angle values in the code if needed.
Moisture Sensor Calibration
Open Serial Monitor (Serial.begin(9600) + Serial.println(analogRead(A0))). Put the sensor prongs in dry soil and note the number. Put in wet soil — note that number. Set SOIL_DRY_VAL in the code to a value between those two readings.
Full Field Run!
Fill the seed hopper with small seeds (mung beans, coriander, sesame work great!). Press the SOW button and set the rover on a prepared soil patch. Watch it plant! Repeat with each mode. Congratulations — you just ran an automated farm!
🚀Cool Upgrades to Try Next
Add GPS Navigation
Mount a NEO-6M GPS module and program the rover to follow a set of GPS waypoints across a real field automatically.
Bluetooth Remote Control
Add an HC-05 Bluetooth module and control the rover from a free Arduino Bluetooth app on your phone.
Wi-Fi + Data Dashboard
Swap to an ESP32 and log soil moisture readings to a Google Sheet or a Blynk dashboard in real-time.
Camera + Plant Disease AI
Mount an ESP32-CAM and train a TensorFlow Lite model to spot diseased leaves — the rover could flag them for treatment!
Solar Charging Panel
Strap a small 5V solar panel to the top deck to charge a power bank that keeps the rover running all day on sunlight!
Ultrasonic Obstacle Avoidance
Add an HC-SR04 ultrasonic sensor to the front so the rover automatically stops and turns when it hits the field boundary or an obstacle.

Comments
Post a Comment