Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater

Arduino Automatic Cooker Project – Servo, Temperature & Relay Control | MakeMindz
Arduino Automation Project

Arduino Automatic Cooker
with Servo, Temperature & Relay Control

A fully automated 15-minute cooking system — ingredient dispensing via 4 servo motors, automatic DC motor stirring, relay-controlled heater, and real-time temperature monitoring with LCD feedback.

2–3 Hours Build
Intermediate Level
Arduino UNO + C++
Simulation Available
Arduino Automatic Cooker Project with servo motors, DC stirrer, relay heater and temperature sensor

Components Required

Gather all the hardware listed below before starting the build. Most parts are available from popular electronics stores or online.

🟧
Arduino UNOMain microcontroller
⚙️
SG90 Servo Motors × 4Ingredient container control
🔵
DC Motor + L298N DriverAutomatic stirring
🔴
Relay Module (5V)Heater element switching
🌡️
Temperature SensorNTC or DS18B20 type
📺
16×2 LCD DisplayStatus & temperature readout
⌨️
4×4 Keypad ModuleUser input & mode selection
🎛️
Potentiometer 10kΩLCD contrast / temp set
🔋
Power Supply9V battery + 5V adapter
🔌
Jumper Wires + BreadboardPrototyping connections

How It Works

The system runs a 15-minute automated cooking cycle divided into timed phases. The user first selects a cooking mode via the 4×4 keypad. Once started, the Arduino orchestrates every action:

  • Each of the 4 servo motors opens its ingredient container at a specific minute during the cycle.
  • The DC motor (via L298N) stirs the pot continuously or at programmed intervals, with speed controlled by PWM.
  • The relay module switches the heater element ON and OFF based on the cooking phase and current temperature reading.
  • The temperature sensor on pin A0 continuously samples heat; if it exceeds 70 °C the heater shuts off automatically as a safety measure.
  • The LCD display shows the current temperature, remaining cook time, and the active step (Dispensing / Stirring / Heating).

This is a great demonstration of real-time embedded control combining timer-based logic, sensor feedback, and multi-actuator sequencing — all on a single Arduino UNO.

Pin Connections

Connect each component to the Arduino UNO as shown in the table below. Double-check polarity on the relay and motor driver before powering up.

Component Arduino Pin Notes
Servo Motor 1 (Container 1)D2Signal wire; Vcc to 5V
Servo Motor 2 (Container 2)D3Signal wire; Vcc to 5V
Servo Motor 3 (Container 3)D4Signal wire; Vcc to 5V
Servo Motor 4 (Container 4)D5Signal wire; Vcc to 5V
Relay Module (IN)D7Active-HIGH control signal
L298N – ENA (Motor Enable)D8PWM speed control
L298N – IN1D9Motor direction
L298N – IN2D10Motor direction
Temperature Sensor (OUT)A0Analog 10mV/°C assumed
LCD RSD12Register Select
LCD END11Enable
LCD D4–D7D6, D5, D4, D34-bit data mode
4×4 KeypadA1–A4, DRow/Col pins (adjust as needed)
Potentiometer (wiper)LCD VO pinContrast adjustment

Block Diagram

System Architecture — Arduino Automatic Cooker

Arduino UNO ATmega328P D2-D12 · A0 4× SG90 Servos Ingredient dispensing Pins D2, D3, D4, D5 4×4 Keypad User mode selection Analog/Digital Pins 16×2 LCD Temp · Time · Status D3,D4,D5,D6,D11,D12 Temp Sensor NTC / DS18B20 Pin A0 Relay Module Controls heater element Pin D7 Heater Element Relay-switched (AC/DC) DC Motor + L298N Stirring mechanism Pins D8 (PWM), D9, D10 Potentiometer LCD contrast adjust ─ ─ optional / indirect connection direct connection

Step-by-Step Instructions

1
Gather & verify all components

Check off every item from the components list. Test each servo motor individually using a servo tester or simple sketch before integrating.

2
Prepare the Arduino IDE

Install the Servo library (pre-bundled with IDE). If using DS18B20 instead of NTC, also install OneWire and DallasTemperature libraries via Library Manager.

Board: Arduino UNO · Port: COMx (Windows) or /dev/ttyUSBx (Linux/Mac)
3
Wire the servo motors

Connect the signal (orange/yellow) wires of SG90 servos to D2, D3, D4, D5 respectively. Power all four servos from a shared 5V rail with a common GND back to Arduino.

Use an external 5V source for servos — drawing all 4 from the Arduino 5V pin can cause brownout resets.
4
Connect the L298N motor driver

Wire ENA → D8 (PWM), IN1 → D9, IN2 → D10. Connect the DC motor to OUT1 and OUT2. Power the L298N 12V input from your external supply; bridge the 5V enable jumper if your supply is under 12V.

5
Set up the relay and heater

Connect the relay IN pin to D7. Wire the heater element through the relay's NO (Normally Open) terminal and COM. The heater can be AC or DC — ensure the relay's rated voltage matches.

⚠️ If using mains AC voltage for the heater, have this wired by a qualified person. Always test with a low-voltage DC heater first.
6
Connect the temperature sensor

For NTC: connect one leg to 5V via a 10kΩ pull-up resistor, the middle junction to A0, and the other leg to GND. For DS18B20: use a 4.7kΩ pull-up on the data line to 5V, data to A0 (or any digital pin with OneWire).

7
Wire the LCD and potentiometer

Connect the 16×2 LCD in 4-bit mode: RS→D12, EN→D11, D4–D7→D6,D5,D4,D3. Run the potentiometer wiper to the LCD VO (contrast) pin.

8
Connect the 4×4 keypad

Wire the 8 keypad pins to available Arduino pins. Update the pin mapping in your sketch's Keypad library initialisation to match your physical wiring.

9
Upload the Arduino sketch

Copy the code from Section 7, paste into Arduino IDE, select Board: Arduino UNO and the correct COM port, then click Upload. Open the Serial Monitor (9600 baud) to verify output.

10
Test each stage independently
  • Manually trigger each servo to confirm it reaches 90° (open position).
  • Call controlMotor(15) in setup to verify stirring direction and speed.
  • Toggle the relay manually: digitalWrite(7, HIGH) → confirm heater activates.
  • Check A0 readings in Serial Monitor against a thermometer.

Arduino Code

The complete sketch below uses only the built-in Servo.h library. Copy it directly into your Arduino IDE.

automatic_cooker.ino
/*
 * Automatic Cooker — MakeMindz.com
 * Controls servo dispensers, DC stirrer, relay heater,
 * and temperature sensor across a 15-minute cook cycle.
 */

#include <Servo.h>

const int servoPins[4] = {2, 3, 4, 5};
const int relayPin       = 7;
const int tempSensorPin  = A0;
const int motorEnablePin = 8;
const int motorIn1Pin    = 9;
const int motorIn2Pin    = 10;

Servo servos[4];
unsigned long startTime;

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

  for (int i = 0; i < 4; i++) {
    servos[i].attach(servoPins[i]);
    servos[i].write(0);           // closed position
  }

  pinMode(relayPin,       OUTPUT);
  pinMode(motorEnablePin, OUTPUT);
  pinMode(motorIn1Pin,    OUTPUT);
  pinMode(motorIn2Pin,    OUTPUT);

  startTime = millis();
}

void loop() {
  unsigned long elapsed = (millis() - startTime) / 1000UL;

  // Read temperature (NTC: 10mV/°C assumption)
  int   raw  = analogRead(tempSensorPin);
  float temp = (raw / 1024.0) * 500.0;

  Serial.print("Temp: "); Serial.print(temp); Serial.println(" C");

  // Safety: cut heater if over 70 °C
  if (temp > 70) digitalWrite(relayPin, LOW);

  // === 15-minute cook sequence ===
  if (elapsed < 180) {
    // 0–3 min: Initial heating
    digitalWrite(relayPin, HIGH);

  } else if (elapsed < 300) {
    // 3–5 min: Dispense ingredient 1
    servos[0].write(90);

  } else if (elapsed < 420) {
    // 5–7 min: Dispense ingredient 2
    servos[1].write(90);

  } else if (elapsed < 540) {
    // 7–9 min: Dispense ingredient 4
    servos[3].write(90);

  } else if (elapsed < 840) {
    // 9–14 min: Heat + stir at 15 RPM
    digitalWrite(relayPin, HIGH);
    controlMotor(15);

  } else if (elapsed < 1140) {
    // Continue stirring at 15 RPM
    controlMotor(15);

  } else if (elapsed < 1200) {
    // Final minute: slow stir at 5 RPM
    controlMotor(5);

  } else {
    // Cooking complete
    digitalWrite(relayPin, LOW);
    controlMotor(0);
  }
}

void controlMotor(int rpm) {
  if (rpm == 0) {
    analogWrite(motorEnablePin, 0);
    digitalWrite(motorIn1Pin, LOW);
    digitalWrite(motorIn2Pin, LOW);
    return;
  }
  int speed = map(rpm, 5, 15, 128, 255);
  analogWrite(motorEnablePin, speed);
  digitalWrite(motorIn1Pin, HIGH);
  digitalWrite(motorIn2Pin, LOW);
}

Cooking Timeline (15 Minutes)

The full cooking cycle runs exactly 900 seconds. Here's what happens at each stage:

0:00 – 3:00
⚡ Initial Heating Phase
Relay ON → heater warms the pot. Servo containers remain closed. Temperature monitored continuously.
3:00 – 5:00
🥄 Dispense Ingredient 1
Servo 1 rotates to 90° (open) — releases first ingredient into the warm pot.
5:00 – 7:00
🥄 Dispense Ingredient 2
Servo 2 opens at 90° — second ingredient added.
7:00 – 9:00
🥄 Dispense Ingredient 4
Servo 4 opens — fourth ingredient dispensed (ingredient 3 can be added manually or extend the sequence).
9:00 – 14:00
🔥 Heat + Stir (15 RPM)
Relay ON + DC motor at 15 RPM (PWM 255). Heater auto-cuts if temperature exceeds 70 °C.
14:00 – 19:00
🌀 Continue Stirring (15 RPM)
Continued stirring without additional heating — coasts on residual heat.
19:00 – 20:00
🐌 Final Slow Stir (5 RPM)
Motor slows to PWM 128 — gentle final mix before process ends.
20:00+
✅ Cooking Complete
Relay OFF, motor stopped. LCD displays completion message.

Try the Simulation

Test this project in your browser using Cirkit Designer or Wokwi — no hardware required to get started.

Cirkit Designer Simulation

Full schematic with all components — run the code live

Open Simulation →

Wokwi Online Simulator

Paste the code into Wokwi's Arduino UNO project for instant simulation

Open Wokwi →

Key Features

⏱️
15-Min Auto Cycle

Fully timed cooking sequence, no manual intervention needed.

🍯
Multi-Servo Dispensing

4 independent ingredient containers released at precise intervals.

🌀
Variable Speed Stirring

PWM-controlled DC motor: 15 RPM cooking, 5 RPM finish.

🌡️
Thermal Safety Cutoff

Heater auto-shuts at 70 °C preventing overcooking or fire risk.

📺
Real-Time LCD Feedback

Live temperature, countdown timer, and current step displayed.

🔒
Relay-Safe Heating

Isolated relay switching — Arduino never touches heater voltage.

⌨️
Keypad Mode Selection

User picks cooking mode before start via 4×4 keypad input.

🧩
Expandable Design

Add more servos, sensors or WiFi (ESP8266) for IoT control.

Made with ❤️ by MakeMindz — Arduino, IoT & Embedded Systems Tutorials

Have questions? Drop a comment on the original post.

Comments

try for free