Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
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.
Components Required
Gather all the hardware listed below before starting the build. Most parts are available from popular electronics stores or online.
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) | D2 | Signal wire; Vcc to 5V |
| Servo Motor 2 (Container 2) | D3 | Signal wire; Vcc to 5V |
| Servo Motor 3 (Container 3) | D4 | Signal wire; Vcc to 5V |
| Servo Motor 4 (Container 4) | D5 | Signal wire; Vcc to 5V |
| Relay Module (IN) | D7 | Active-HIGH control signal |
| L298N – ENA (Motor Enable) | D8 | PWM speed control |
| L298N – IN1 | D9 | Motor direction |
| L298N – IN2 | D10 | Motor direction |
| Temperature Sensor (OUT) | A0 | Analog 10mV/°C assumed |
| LCD RS | D12 | Register Select |
| LCD EN | D11 | Enable |
| LCD D4–D7 | D6, D5, D4, D3 | 4-bit data mode |
| 4×4 Keypad | A1–A4, D | Row/Col pins (adjust as needed) |
| Potentiometer (wiper) | LCD VO pin | Contrast adjustment |
Block Diagram
System Architecture — Arduino Automatic Cooker
Step-by-Step Instructions
Check off every item from the components list. Test each servo motor individually using a servo tester or simple sketch before integrating.
Install the Servo library (pre-bundled with IDE). If using DS18B20 instead of NTC, also install OneWire and DallasTemperature libraries via Library Manager.
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.
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.
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.
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).
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.
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.
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.
- 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 — 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:
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
Wokwi Online Simulator
Paste the code into Wokwi's Arduino UNO project for instant simulation
Key Features
Fully timed cooking sequence, no manual intervention needed.
4 independent ingredient containers released at precise intervals.
PWM-controlled DC motor: 15 RPM cooking, 5 RPM finish.
Heater auto-shuts at 70 °C preventing overcooking or fire risk.
Live temperature, countdown timer, and current step displayed.
Isolated relay switching — Arduino never touches heater voltage.
User picks cooking mode before start via 4×4 keypad input.
Add more servos, sensors or WiFi (ESP8266) for IoT control.
Comments
Post a Comment