Introduction to IoT
Unit 5: Actuators & Motors
From DC motors to servos and relays โ master the output side of IoT. Make things move, spin, and switch using Arduino.
โฑ๏ธ Time to Complete: 6โ8 hours | ๐ฐ Build a DIY Robot Car for โน500 | ๐ 30 MCQs (Bloom's Mapped)
๐ผ Skills unlocked: Motor control, PWM speed regulation, Servo positioning, Relay switching, H-bridge driver circuits
What are Actuators?
๐ง Sensors See, Actuators DO
In Unit 3 and 4, you learned how sensors let your Arduino "see" the world โ temperature, light, distance, motion. But what good is sensing if your system can't act on it? Actuators are the muscles of IoT. They convert electrical signals into physical motion, force, or action.
When your smart fan turns on because the temperature crossed 35ยฐC โ that's an actuator (motor). When your automatic door opens โ that's an actuator (servo). When Alexa turns on your tube light โ that's an actuator (relay). Without actuators, IoT would just be "I" โ the Internet of sensors staring at data, doing nothing.
Types of Actuators in IoT
โก Actuator Classification
An actuator is a device that converts an electrical signal into a physical output โ motion, rotation, linear displacement, sound, or switching.
| Actuator Type | What It Does | Example | IoT Use Case |
|---|---|---|---|
| DC Motor | Continuous rotation | Fan, car wheel | Robot car, conveyor belt |
| Servo Motor | Precise angular rotation (0ยฐโ180ยฐ) | Robot arm, door lock | Automated gate, camera pan/tilt |
| Stepper Motor | Discrete step rotation (precise) | 3D printer, CNC | Precision positioning |
| Solenoid | Linear push/pull motion | Door lock, valve | Automatic door lock |
| Relay | Electrical switch (ON/OFF) | Light switch | Home automation (AC appliances) |
| Piezo Buzzer | Produces sound | Alarm beep | Alert system, doorbell |
| LED | Produces light | Indicator | Status display, smart lighting |
In this unit, we'll focus on the three most important actuators for IoT beginners: DC Motors, Servo Motors, and Relay Modules. These three cover 90% of all student IoT projects.
DC Motor Basics โ How It Works
The Science Inside a DC Motor
A DC motor converts electrical energy into mechanical rotational energy. Inside, it has a coil of wire (armature) sitting inside a magnetic field. When current flows through the coil, it creates a force (Lorentz force) that makes the coil spin. The direction of spin depends on the direction of current.
๐ DC Motor Key Parameters
| Parameter | What It Means | Typical Value (Small Hobby Motor) |
|---|---|---|
| Operating Voltage | Voltage needed to run the motor | 3V โ 12V |
| Current Draw | Current consumed when running | 100mA โ 300mA (no load), up to 1A (stall) |
| RPM | Rotations Per Minute โ speed | 3000 โ 15000 RPM |
| Torque | Rotational force | Low (needs gearbox for heavy loads) |
| Stall Current | Current when motor is blocked/stuck | 500mA โ 2A (dangerous!) |
Why You CANNOT Connect a DC Motor Directly to Arduino
This is the #1 mistake every beginner makes. Let's understand why:
Arduino digital pin can supply: Maximum 20mA (recommended), 40mA (absolute max).
DC motor needs: 100โ300mA minimum, up to 1A when starting or stalling.
That's 5โ50ร more current than Arduino can provide. Doing this can burn out the ATmega328P chip permanently. Additionally, motors generate back-EMF (voltage spikes) when turning off, which can fry the microcontroller.
The Solution? Use a motor driver IC like the L293D. The motor driver acts as a middleman โ it takes the small control signal from Arduino and uses a separate power supply to drive the motor with the current it needs.
Analogy Think of it like this: Arduino Pin = TV Remote (sends signal, tiny power) Motor Driver = AC Power Socket (provides actual power) DC Motor = Television (needs real power to work) You use the remote to CONTROL what happens, but the TV gets its POWER from the wall socket. The motor driver is that wall socket for your motor.
L293D Motor Driver โ Dual H-Bridge IC
What is an H-Bridge?
An H-bridge is a circuit that allows you to control the direction of a DC motor. It uses 4 switches arranged in an "H" shape. By toggling different pairs of switches, current flows through the motor in either direction:
ASCII
H-Bridge Circuit
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ S1 โโโ โโโ S3 โ
โ โ โ โ
+V โโโโโโโโซ โฃโโโโโโโ +V
โ โ โ โ
โ โโโโดโโโโโโดโโโ โ
โ โ MOTOR โ โ
โ โ โฒ or โณ โ โ
โ โโโโฌโโโโโโฌโโโ โ
โ โ โ โ
GND โโโโโโโซ โฃโโโโโโ GND
โ โ โ โ
โ S2 โโโ โโโ S4 โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
FORWARD: S1=ON, S4=ON, S2=OFF, S3=OFF โ Current: Left to Right
REVERSE: S3=ON, S2=ON, S1=OFF, S4=OFF โ Current: Right to Left
BRAKE: S1=ON, S3=ON (or S2+S4) โ Motor shorts, stops quickly
COAST: All OFF โ Motor spins freely to stop
The L293D IC contains two complete H-bridges in a single 16-pin DIP package, meaning it can control 2 motors independently.
L293D Pin Diagram (16-Pin DIP)
ASCII
L293D โ Top View
โโโโโโโโโโ โโโโโโโโโโ
Enable1 โโโค 1 16 โโโ Vss (+5V Logic)
Input1 โโโค 2 15 โโโ Input4
Output1 โโโค 3 14 โโโ Output4
GND โโโค 4 13 โโโ GND
GND โโโค 5 12 โโโ GND
Output2 โโโค 6 11 โโโ Output3
Input2 โโโค 7 10 โโโ Input3
Vs (Motor) โโค 8 9 โโโ Enable2
โโโโโโโโโโโโโโโโโโโโโโโ
Pin 16 (Vss) = +5V (Logic supply from Arduino)
Pin 8 (Vs) = Motor supply voltage (6Vโ12V from battery)
Pins 4,5,12,13 = GND (also act as heat sinks)
L293D Pin Functions
| Pin | Name | Function |
|---|---|---|
| 1 | Enable1 | Enables Motor A (HIGH=ON). Connect to PWM pin for speed control. |
| 2 | Input1 | Control pin A1 โ direction control for Motor A |
| 3 | Output1 | Motor A terminal 1 โ connect to motor wire |
| 4, 5 | GND | Ground (solder to copper ground plane for heat dissipation) |
| 6 | Output2 | Motor A terminal 2 โ connect to other motor wire |
| 7 | Input2 | Control pin A2 โ direction control for Motor A |
| 8 | Vs | Motor power supply (6Vโ12V from battery pack) |
| 9 | Enable2 | Enables Motor B (HIGH=ON). Connect to PWM pin for speed control. |
| 10 | Input3 | Control pin B1 โ direction control for Motor B |
| 11 | Output3 | Motor B terminal 1 |
| 12, 13 | GND | Ground (heat sink) |
| 14 | Output4 | Motor B terminal 2 |
| 15 | Input4 | Control pin B2 โ direction control for Motor B |
| 16 | Vss | Logic supply voltage (+5V from Arduino) |
L293D Truth Table โ Direction Control
| Enable | Input1 | Input2 | Motor Action |
|---|---|---|---|
| HIGH | HIGH | LOW | โณ Forward (clockwise) |
| HIGH | LOW | HIGH | โฒ Reverse (counter-clockwise) |
| HIGH | HIGH | HIGH | ๐ Brake (motor locked) |
| HIGH | LOW | LOW | โธ Coast (motor free-spins to stop) |
| LOW | X | X | โน Motor OFF (disabled) |
analogWrite(enablePin, speed) where speed is 0โ255. At 0, motor is off; at 127, motor runs at ~50% speed; at 255, full speed.
Interfacing DC Motor with Arduino via L293D
Circuit Diagram
ASCII Circuit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ARDUINO UNO โ
โ โ
โ Pin 9 (PWM) โโโโโโโโโโโ Enable1 (Pin 1) โ
โ Pin 2 โโโโโโโโโโโโโโโโโโ Input1 (Pin 2) โ
โ Pin 3 โโโโโโโโโโโโโโโโโโ Input2 (Pin 7) โ
โ 5V โโโโโโโโโโโโโโโโโโ Vss (Pin 16) โ
โ GND โโโฌโโโโโโโโโโโโโโโ GND (Pin 4,5, โ
โ โ 12,13) โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L293D โ โ
โ โ โ
โ Output1 (Pin 3) โโโโโโ Motor Terminal A โ
โ Output2 (Pin 6) โโโโโโ Motor Terminal B โ
โ โ
โ Vs (Pin 8) โโโโโโโโโโโ Battery + (6Vโ9V) โ
โ GND (Pin 4,5,12,13) โโ Battery GND โโ Ard GNDโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โก Battery Pack: 4รAA (6V) or 9V battery
โ ๏ธ Common GND between Arduino and Battery is CRITICAL!
Connection Table
| Arduino Pin | L293D Pin | Purpose |
|---|---|---|
| Pin 9 (PWM ~) | Pin 1 (Enable1) | Speed control via PWM |
| Pin 2 | Pin 2 (Input1) | Direction control A |
| Pin 3 | Pin 7 (Input2) | Direction control B |
| 5V | Pin 16 (Vss) | Logic power supply |
| GND | Pins 4, 5, 12, 13 | Common ground |
| โ | Pin 8 (Vs) | Battery positive (6Vโ9V) |
| โ | Pins 3, 6 (Outputs) | Motor terminals |
Arduino Code: Forward, Reverse, Stop
Arduino // DC Motor Control with L293D // Forward โ Reverse โ Stop (repeat) const int enablePin = 9; // PWM pin for speed const int in1 = 2; // Input1 of L293D const int in2 = 3; // Input2 of L293D void setup() { pinMode(enablePin, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); analogWrite(enablePin, 200); // ~78% speed } void loop() { // โโ FORWARD โโ digitalWrite(in1, HIGH); digitalWrite(in2, LOW); delay(3000); // Run forward for 3 seconds // โโ STOP โโ digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(1000); // Pause 1 second // โโ REVERSE โโ digitalWrite(in1, LOW); digitalWrite(in2, HIGH); delay(3000); // Run reverse for 3 seconds // โโ STOP โโ digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(1000); }
Speed Control with analogWrite
Arduino // Gradually increase speed, then decrease void loop() { digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Ramp UP: 0 โ 255 for (int speed = 0; speed <= 255; speed += 5) { analogWrite(enablePin, speed); delay(50); } // Ramp DOWN: 255 โ 0 for (int speed = 255; speed >= 0; speed -= 5) { analogWrite(enablePin, speed); delay(50); } delay(1000); }
Controlling Direction & Speed via Serial Monitor
Let's build an interactive motor controller. You type a command in the Serial Monitor, and the motor responds:
Arduino // Interactive DC Motor Control via Serial // Commands: F = Forward, B = Backward, S = Stop // Speed: 0-9 (0=off, 9=max) const int enablePin = 9; const int in1 = 2; const int in2 = 3; int motorSpeed = 200; void setup() { Serial.begin(9600); pinMode(enablePin, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); Serial.println("=== DC Motor Controller ==="); Serial.println("Commands:"); Serial.println(" F = Forward"); Serial.println(" B = Backward"); Serial.println(" S = Stop"); Serial.println(" 0-9 = Speed (0=off, 9=max)"); } void loop() { if (Serial.available() > 0) { char cmd = Serial.read(); switch (cmd) { case 'F': case 'f': digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enablePin, motorSpeed); Serial.print("โถ Forward at speed: "); Serial.println(motorSpeed); break; case 'B': case 'b': digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enablePin, motorSpeed); Serial.print("โ Backward at speed: "); Serial.println(motorSpeed); break; case 'S': case 's': digitalWrite(in1, LOW); digitalWrite(in2, LOW); analogWrite(enablePin, 0); Serial.println("โน Motor STOPPED"); break; default: // Check if it's a speed digit 0-9 if (cmd >= '0' && cmd <= '9') { motorSpeed = map(cmd - '0', 0, 9, 0, 255); analogWrite(enablePin, motorSpeed); Serial.print("๐ง Speed set to: "); Serial.println(motorSpeed); } break; } } }
Multiple DC Motors โ Robot Car Concept
The L293D can drive 2 DC motors simultaneously โ perfect for a 2-wheel drive (2WD) robot car. Motor A controls the left wheel, Motor B controls the right wheel.
Robot Car Movement Logic
| Movement | Left Motor (A) | Right Motor (B) |
|---|---|---|
| โฌ๏ธ Forward | Forward | Forward |
| โฌ๏ธ Backward | Reverse | Reverse |
| โฌ ๏ธ Turn Left | Stop (or Reverse) | Forward |
| โก๏ธ Turn Right | Forward | Stop (or Reverse) |
| ๐ Spin Left | Reverse | Forward |
| ๐ Spin Right | Forward | Reverse |
| โน Stop | Stop | Stop |
Arduino // 2WD Robot Car โ Full Motor Control // Motor A (Left) const int enA = 9; const int in1 = 2; const int in2 = 3; // Motor B (Right) const int enB = 10; const int in3 = 4; const int in4 = 5; int speed = 200; void setup() { pinMode(enA, OUTPUT); pinMode(enB, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); } void moveForward() { analogWrite(enA, speed); analogWrite(enB, speed); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); } void moveBackward() { analogWrite(enA, speed); analogWrite(enB, speed); digitalWrite(in1, LOW); digitalWrite(in2, HIGH); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); } void turnLeft() { analogWrite(enA, 0); analogWrite(enB, speed); digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); } void turnRight() { analogWrite(enA, speed); analogWrite(enB, 0); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); } void stopMotors() { analogWrite(enA, 0); analogWrite(enB, 0); digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); } void loop() { moveForward(); delay(2000); turnRight(); delay(800); moveForward(); delay(2000); turnLeft(); delay(800); moveBackward(); delay(1000); stopMotors(); delay(2000); }
You can build a fully functional 2WD robot car for under โน500:
โข Arduino Uno clone: โน250 (Robu.in)
โข L293D IC: โน30
โข 2ร BO motors with wheels: โน80
โข Battery holder (4รAA): โน20
โข Chassis (cardboard/acrylic cut): โน30
โข Jumper wires: โน40
โข Castor wheel: โน25
Total: โน475
Compare this to commercial robot car kits on Amazon.in that cost โน3,000โโน5,000 โ and you'll learn 10ร more building it yourself. Add an HC-05 Bluetooth module (โน180) and control it from your phone!
Servo Motor โ Precise Angle Control
How a Servo Motor Works
A servo motor is NOT like a DC motor. It doesn't just spin continuously. Instead, it moves to a specific angle and holds that position. It contains:
๐ฏ Inside a Servo Motor โ The Feedback Loop
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ SERVO MOTOR โ โ โ โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ โ โ CONTROL โโโโโถโ DC โโโโโถโ GEAR โ โ โ โ CIRCUIT โ โ MOTOR โ โ TRAIN โโโโโ OUTPUT โ โ โ โ โ โ โ โ SHAFT โ โโโโโโฒโโโโโโ โโโโโโโโโโโโ โโโโโโฌโโโโโโ โ โ โ โ โ โ โ โโโโโโโโโโโโ โ โ โ โโโโโโโโโโโ POSITION โโโโโโโโโโโโ โ โ โ SENSOR โ (Potentiometer) โ โ โ (Feedback)โ โ โ โโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 1. Arduino sends PWM signal (pulse width = desired angle) 2. Control circuit compares desired angle vs actual angle 3. If there's a difference, motor rotates to correct it 4. Potentiometer on shaft reports actual position 5. When desired = actual โ motor stops โ holds position THIS IS A CLOSED-LOOP FEEDBACK SYSTEM!
Types of Servo Motors
| Feature | Standard Servo (180ยฐ) | Continuous Rotation Servo |
|---|---|---|
| Rotation Range | 0ยฐ to 180ยฐ (half circle) | Full 360ยฐ continuous |
| Control | servo.write(angle) โ sets position | servo.write(speed) โ 90=stop, 0=full CW, 180=full CCW |
| Use Case | Robot arm, gate, camera pan | Wheels, winch, continuous rotation |
| Has Feedback? | Yes โ holds exact angle | No position feedback (just speed control) |
SG90 Micro Servo โ The IoT Workhorse
| Specification | Value |
|---|---|
| Operating Voltage | 4.8V โ 6V |
| Torque | 1.8 kgยทcm (at 4.8V) |
| Speed | 0.1 sec / 60ยฐ (at 4.8V) |
| Rotation Range | 0ยฐ โ 180ยฐ |
| Weight | 9 grams |
| Signal | PWM (50Hz, 1โ2ms pulse width) |
| Price (India) | โน60 โ โน100 |
ASCII
Servo PWM Signal (50Hz = 20ms period)
0ยฐ (1.0ms pulse): โโโโโโ โโโโโโ
90ยฐ (1.5ms pulse): โโโโโโโโ โโโโโโโโ
180ยฐ(2.0ms pulse): โโโโโโโโโโ โโโโโโโโโโ
โโโ 20ms (1 period) โโโโโโโค
Pulse Width โ Servo Position
1.0 ms โ 0ยฐ (full left)
1.5 ms โ 90ยฐ (centre)
2.0 ms โ 180ยฐ (full right)
Interfacing Servo Motor with Arduino
Circuit Diagram
ASCII Circuit
โโโโโโโโโโโโโโโโโโโโโโ
โ ARDUINO UNO โ
โ โ
โ Pin 9 โโโโโโโโโโโผโโโโโโ Orange/Yellow (Signal)
โ 5V โโโโโโโโโโโผโโโโโโ Red (VCC)
โ GND โโโโโโโโโโโผโโโโโโ Brown (GND)
โ โ
โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ
โ SG90 โ
Signal โโโโโโโโโโโโโโโโโโโ SERVO โ
VCC โโโโโโโโโโโโโโโโโโโ MOTOR โ
GND โโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโ
โ ๏ธ SG90 has 3 wires:
๐ค Brown = GND
๐ด Red = VCC (+5V)
๐ Orange = Signal (PWM)
๐ก For 1โ2 servos, Arduino 5V is fine.
โก For 3+ servos, use external 5V power supply!
Connection Table
| Servo Wire | Color | Arduino Pin | Purpose |
|---|---|---|---|
| Signal | Orange / Yellow / White | Pin 9 (PWM) | Control angle via PWM |
| VCC | Red | 5V | Power supply |
| GND | Brown / Black | GND | Ground reference |
Arduino Code โ Servo Sweep
Arduino // Servo Sweep: 0ยฐ โ 180ยฐ โ 0ยฐ continuously // Uses the built-in Servo library #include <Servo.h> Servo myServo; // Create servo object void setup() { myServo.attach(9); // Attach servo to Pin 9 Serial.begin(9600); } void loop() { // Sweep from 0ยฐ to 180ยฐ for (int angle = 0; angle <= 180; angle++) { myServo.write(angle); Serial.print("Angle: "); Serial.println(angle); delay(15); // 15ms for smooth motion } // Sweep from 180ยฐ to 0ยฐ for (int angle = 180; angle >= 0; angle--) { myServo.write(angle); Serial.print("Angle: "); Serial.println(angle); delay(15); } }
Key Servo Library Functions
| Function | What It Does | Example |
|---|---|---|
Servo myServo; | Creates a servo object | Can create up to 12 on Uno |
myServo.attach(pin) | Connects servo to a pin | myServo.attach(9); |
myServo.write(angle) | Moves servo to angle (0โ180) | myServo.write(90); โ centre |
myServo.read() | Returns current angle | int pos = myServo.read(); |
myServo.detach() | Disconnects servo (saves power) | myServo.detach(); |
delay() for long periods when using servos. The Servo library generates PWM signals in the background. A long delay() is fine โ the servo holds position. BUT if you use delayMicroseconds() for very long periods or disable interrupts, the servo signal may glitch. Use millis()-based timing for complex projects.
Potentiometer-Controlled Servo
This is one of the most satisfying IoT circuits to build โ turn a knob and watch the servo follow your hand in real-time!
Circuit Diagram
ASCII Circuit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ARDUINO UNO โ
โ โ
โ A0 โโโโโโโโโโโโ Potentiometer WIPER โ
โ Pin 9 โโโโโโโโโ Servo Signal (Orange) โ
โ 5V โโโฌโโโโโโโโโ Servo VCC (Red) โ
โ โโโโโโโโโโ Pot Pin 1 (VCC) โ
โ GND โโฌโโโโโโโโโ Servo GND (Brown) โ
โ โโโโโโโโโโ Pot Pin 3 (GND) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
POTENTIOMETER (10Kฮฉ)
โโโโโโโโโโโโโโโโโโโ
โ 1 2 3 โ
โ VCC WIPER GNDโ
โ (+5V) (A0) โ
โโโโโโโโโโโโโโโโโโโ
Turn the knob โ Voltage at A0 changes (0Vโ5V)
Arduino reads: 0โ1023 โ maps to 0ยฐโ180ยฐ
Servo follows the knob position!
Connection Table
| Component | Pin | Arduino Pin |
|---|---|---|
| Potentiometer Pin 1 | VCC | 5V |
| Potentiometer Pin 2 | Wiper (output) | A0 |
| Potentiometer Pin 3 | GND | GND |
| Servo Signal | Orange | Pin 9 |
| Servo VCC | Red | 5V |
| Servo GND | Brown | GND |
Arduino Code
Arduino // Potentiometer-Controlled Servo Motor // Turn the knob โ servo follows #include <Servo.h> Servo myServo; const int potPin = A0; // Analog input void setup() { myServo.attach(9); Serial.begin(9600); } void loop() { int potValue = analogRead(potPin); // Read: 0โ1023 int angle = map(potValue, 0, 1023, 0, 180); // Map to 0ยฐโ180ยฐ myServo.write(angle); // Move servo Serial.print("Pot: "); Serial.print(potValue); Serial.print(" โ Angle: "); Serial.println(angle); delay(15); // Small delay for stability }
map() function is your best friend in IoT. It linearly scales one range to another. Syntax: map(value, fromLow, fromHigh, toLow, toHigh). Use it everywhere: sensor readings to LED brightness, joystick values to motor speed, temperature to fan speed, etc.
Relay Module โ Controlling AC Appliances
How a Relay Works
A relay is an electrically operated switch. It uses a small DC signal (from Arduino) to control a much larger AC circuit (like a tube light, fan, or water pump). Think of it as a tiny servant โ Arduino whispers "turn on," and the relay flips a heavy switch that your Arduino could never handle alone.
๐ Relay Internal Structure
DC Control Side AC Load Side
(Arduino) (Appliance)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโโโโโโ โโโโ COM (Common) โ
โ โ COIL โ โ โ
โ โ (5V DC) โ โโโโโโคโโโ NO (Normally โ
โ โ โ โ โ Open) โ
โ โโโโฌโโโโฌโโโโ โ โ โ
โ โ โ โโโโดโโโ โโโโ NC (Normally โ
โ โ โ โSWITCHโ Closed) โ
โ โ โ โ(Reed)โ โ
โ Signal GND โโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
When Arduino sends HIGH to Signal pin:
โ Coil energises โ creates magnetic field
โ Switch moves from NC to NO
โ Circuit through COM-NO closes โ Appliance turns ON
When Arduino sends LOW:
โ Coil de-energises โ spring pulls switch back
โ Switch returns to NC position
โ COM-NO opens โ Appliance turns OFF
Three AC terminals explained:
| Terminal | Full Name | Meaning |
|---|---|---|
| COM | Common | Always connected โ this goes to one wire of your appliance |
| NO | Normally Open | Disconnected by default. Connects to COM when relay is ON. Use this for most projects. |
| NC | Normally Closed | Connected by default. Disconnects from COM when relay is ON. Use when you want "always ON, signal turns OFF." |
Relay Module Circuit (DC Side โ Safe for Students)
ASCII Circuit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ARDUINO UNO โ
โ โ
โ Pin 7 โโโโโโโโ IN (Relay Signal) โ
โ 5V โโโโโโโโ VCC (Relay Power) โ
โ GND โโโโโโโโ GND (Relay Ground) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ RELAY MODULE (DC Side) โ
โ โ
โ IN โ Signal from Arduino (Pin 7) โ
โ VCC โ 5V from Arduino โ
โ GND โ GND from Arduino โ
โ โ
โ LED โ Indicates relay state (ON/OFF) โ
โ โ
โ โโโ AC Side (COM, NO, NC) โโโ โ
โ โก DO NOT TOUCH AC SIDE โ
โ โก TEACHER SUPERVISION REQUIRED โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Arduino Code โ Relay ON/OFF
Arduino // Relay Module Control // Toggle relay every 3 seconds const int relayPin = 7; void setup() { pinMode(relayPin, OUTPUT); digitalWrite(relayPin, LOW); // Start with relay OFF Serial.begin(9600); Serial.println("Relay Controller Ready"); } void loop() { // Turn relay ON digitalWrite(relayPin, HIGH); Serial.println("๐ก Relay ON โ Appliance is running"); delay(3000); // Turn relay OFF digitalWrite(relayPin, LOW); Serial.println("โซ Relay OFF โ Appliance is stopped"); delay(3000); }
๐ด NEVER touch the AC side of a relay module while it's connected to mains power.
๐ด NEVER work with AC wiring without supervision from a qualified teacher or electrician.
๐ด ALWAYS unplug the appliance from the wall socket before making any wiring changes.
๐ด ALWAYS use a relay module with optocoupler isolation (most modules sold in India have this).
๐ด Students should practice with DC loads only (LED strips, DC fans, DC bulbs) until they have proper training.
๐ด Use a 12V DC bulb or LED strip for testing instead of AC mains โ same concept, zero danger.
For your lab project: Connect the relay to control a 12V DC LED strip or a 5V USB fan. This demonstrates the relay concept safely without any AC mains involvement.
MCQ Assessment Bank โ 30 Questions (Bloom's Mapped)
Remember / Identify (Q1โQ8)
An actuator converts:
- Physical motion into electrical signal
- Electrical signal into physical action
- Analog signal into digital signal
- AC into DC
Which of the following is NOT an actuator?
- DC Motor
- LDR (Light Dependent Resistor)
- Servo Motor
- Relay
The L293D IC contains how many H-bridges?
- 1
- 2
- 4
- 8
What is the maximum current an Arduino digital pin can safely supply?
- 5mA
- 20mA
- 500mA
- 1A
Pin 8 (Vs) of L293D is used for:
- Logic supply voltage (5V)
- Motor supply voltage (6Vโ12V from battery)
- Ground connection
- PWM signal input
SG90 servo motor has a rotation range of:
- 0ยฐ to 90ยฐ
- 0ยฐ to 180ยฐ
- 0ยฐ to 270ยฐ
- 0ยฐ to 360ยฐ
Which Arduino library is used to control servo motors?
- Motor.h
- Servo.h
- Stepper.h
- Wire.h
Servo.h library provides simple functions like attach(), write(), and read() for servo control."NO" on a relay module stands for:
- Not Operating
- Normally Open
- Negative Output
- No Output
Understand / Explain (Q9โQ15)
Why can't you connect a DC motor directly to an Arduino digital pin?
- Arduino doesn't support DC motors
- The motor requires more current than the pin can supply, risking damage to the microcontroller
- DC motors only work with analog pins
- The motor needs AC power, not DC
In the L293D truth table, when Enable=HIGH, Input1=LOW, Input2=LOW, the motor will:
- Spin forward
- Spin backward
- Brake (locked stop)
- Coast (free spin to stop)
What happens inside a servo motor when the desired angle doesn't match the actual angle?
- The servo turns off
- The control circuit drives the motor until the position sensor matches the desired angle
- The servo makes a buzzing sound and stops
- The Arduino automatically adjusts the PWM signal
What is the purpose of the Enable pin on the L293D?
- It sets the motor direction
- It controls whether the motor driver is active and can be used for PWM speed control
- It provides power to the logic circuit
- It connects to the motor terminals
Why do relay modules need optocoupler isolation?
- To increase the relay switching speed
- To electrically isolate the Arduino (low-voltage DC) from the relay coil and AC mains
- To convert AC to DC
- To amplify the signal
The map() function in Arduino is used to:
- Draw maps on an LCD screen
- Re-map a number from one range to another range proportionally
- Create arrays of sensor data
- Map GPS coordinates
map(value, fromLow, fromHigh, toLow, toHigh) linearly scales a value from one range to another. Example: map(512, 0, 1023, 0, 180) returns 90.What is "back-EMF" in the context of DC motors?
- Excess current drawn by the motor
- A voltage spike generated by the motor coil when power is suddenly cut off
- The power consumed by the L293D IC
- The voltage drop across the motor terminals
Apply / Implement (Q16โQ21)
To run a DC motor at approximately 50% speed using L293D, the correct analogWrite() value for the Enable pin is:
- 50
- 127
- 200
- 255
analogWrite(enablePin, 127) gives roughly half speed.To move a servo to 90ยฐ (centre position), the correct code is:
myServo.write(90);analogWrite(9, 90);digitalWrite(9, 90);myServo.attach(90);
servo.write(angle) is the correct Servo library function. analogWrite() sends raw PWM which won't work correctly for servos. attach() is for connecting to a pin, not setting angle.A potentiometer gives analogRead() value of 768. Using map(768, 0, 1023, 0, 180), the servo angle will be approximately:
- 90ยฐ
- 120ยฐ
- 135ยฐ
- 150ยฐ
To make a 2WD robot car turn LEFT, you should:
- Stop both motors
- Run left motor forward, stop right motor
- Stop left motor, run right motor forward
- Reverse both motors
Which pin configuration makes L293D Motor A spin in REVERSE?
- Enable1=HIGH, Input1=HIGH, Input2=LOW
- Enable1=HIGH, Input1=LOW, Input2=HIGH
- Enable1=LOW, Input1=HIGH, Input2=HIGH
- Enable1=HIGH, Input1=HIGH, Input2=HIGH
To use a relay to control a 12V DC LED strip, you should connect the LED strip between:
- VCC and IN pins of relay module
- COM and NO terminals of relay
- Signal and GND pins of Arduino
- Enable and Output pins of L293D
Analyze / Compare (Q22โQ25)
A student's DC motor runs in only one direction regardless of Input1/Input2 values. The most likely cause is:
- The motor is broken
- The Enable pin is not connected (floating)
- One of the Input pins is not connected to Arduino (floating HIGH/LOW randomly)
- The battery is inserted backwards
Comparing DC motor and servo motor: which statement is TRUE?
- Both use open-loop control
- DC motors provide precise angle control; servos provide continuous rotation
- Servos use closed-loop feedback for precise positioning; DC motors use open-loop continuous rotation
- Both require the Servo.h library
A relay module's LED turns ON when digitalWrite(relayPin, LOW) is called. This means the module is:
- Broken
- Active HIGH
- Active LOW
- Short-circuited
Why does the L293D have 4 GND pins (pins 4, 5, 12, 13) instead of just one?
- Manufacturing defect โ only one GND is needed
- They serve as heat sinks โ spreading heat from the IC to the PCB copper
- Each GND controls a different motor
- Two are for DC ground and two for AC ground
Evaluate / Justify (Q26โQ28)
For an automated greenhouse watering system, the best actuator choice is:
- DC motor โ to spin the water
- Servo motor โ to open/close a water valve
- Stepper motor โ for precise water droplet counting
- Piezo buzzer โ to alert the plants
A student uses analogWrite() directly on a servo signal pin instead of Servo.write(). What will happen?
- The servo will work perfectly
- The servo will jitter erratically because analogWrite's PWM frequency (~490Hz) doesn't match servo's required 50Hz
- The servo will move to 0ยฐ and stay there
- The Arduino will crash
analogWrite() runs at ~490Hz. The servo receives incorrect signals and jitters unpredictably. Always use the Servo library.For controlling a 230V AC ceiling fan from an Arduino-based IoT system, the safest approach is:
- Connect fan wires directly to Arduino pins
- Use L293D motor driver
- Use an optocoupler-isolated relay module rated for AC 230V/10A
- Use a servo motor to physically push the fan switch
Create / Design (Q29โQ30)
You're designing an automatic pet feeder that dispenses food at 8 AM and 6 PM. The best actuator combination is:
- 2 DC motors and 1 relay
- 1 servo motor (to open/close food gate) + 1 relay (to control a small vibrating motor for dispensing)
- 3 stepper motors
- 1 piezo buzzer and 1 LED
You're designing a smart parking barrier. The barrier arm should lift to 90ยฐ when a car is detected (ultrasonic sensor) and lower after 10 seconds. Which code logic is correct?
- Read sensor โ if distance < 30cm โ servo.write(90) โ delay(10000) โ servo.write(0)
- Read sensor โ if distance > 100cm โ relay ON โ delay(10000) โ relay OFF
- Read sensor โ DC motor forward โ delay(5000) โ DC motor reverse
- Read sensor โ analogWrite(90) โ delay(10000) โ analogWrite(0)
Short Answer & Long Answer Questions
Short Answer Questions (2โ3 marks each)
Q1. Define an actuator and give three examples used in IoT systems. (2 marks)
Answer: An actuator is a device that converts an electrical signal into a physical output such as motion, force, or switching action. It is the "output" component in the Sense โ Process โ Act IoT loop.
Three examples:
- DC Motor โ provides continuous rotation for robot wheels, fans, conveyor belts
- Servo Motor โ provides precise angular positioning (0ยฐโ180ยฐ) for robot arms, gate barriers, camera mounts
- Relay Module โ acts as an electrically controlled switch to turn ON/OFF AC appliances like lights, pumps, and fans from a microcontroller
Q2. Why is a motor driver IC (like L293D) necessary when interfacing a DC motor with Arduino? (2 marks)
Answer: A motor driver IC is necessary for two critical reasons:
- Current limitation: Arduino digital pins can supply only 20mA (max 40mA), while DC motors require 100mAโ1A or more. Connecting a motor directly can burn the ATmega328P microcontroller chip.
- Back-EMF protection: When a motor stops, its coil generates a reverse voltage spike (back-EMF) that can damage the Arduino. The L293D has built-in protection diodes to safely absorb these spikes.
The motor driver acts as a middleman โ it takes small control signals from Arduino and switches a separate, higher-current power supply to drive the motor.
Q3. Write the L293D truth table for Motor A direction control. (2 marks)
| Enable1 | Input1 | Input2 | Motor A Action |
|---|---|---|---|
| HIGH | HIGH | LOW | Forward (clockwise) |
| HIGH | LOW | HIGH | Reverse (counter-clockwise) |
| HIGH | LOW | LOW | Coast (free spin stop) |
| HIGH | HIGH | HIGH | Brake (locked stop) |
| LOW | X | X | Motor disabled (OFF) |
Key insight: Enable pin must be HIGH for any motor operation. Connecting it to a PWM pin allows speed control via analogWrite().
Q4. Explain the difference between a standard servo (180ยฐ) and a continuous rotation servo. (2 marks)
| Feature | Standard Servo (180ยฐ) | Continuous Rotation Servo |
|---|---|---|
| Rotation | 0ยฐ to 180ยฐ only | Full 360ยฐ continuous |
servo.write(90) | Moves to 90ยฐ position and holds | Stops rotating |
servo.write(0) | Moves to 0ยฐ position | Full speed clockwise |
servo.write(180) | Moves to 180ยฐ position | Full speed counter-clockwise |
| Feedback | Has position feedback (holds angle) | No position feedback |
| Use case | Robot arm, gate, camera mount | Wheels, winch, rotating platform |
The standard servo is most common in IoT projects because precise angle control is usually needed.
Q5. What do COM, NO, and NC mean on a relay module? Which should you use for turning an appliance ON/OFF? (2 marks)
COM (Common): The common terminal that is always connected to one wire of the load (appliance).
NO (Normally Open): This terminal is disconnected from COM by default. When the relay is activated (coil energised), it connects to COM, completing the circuit. Use COM-NO for most ON/OFF applications โ appliance is OFF by default, turns ON when Arduino activates the relay.
NC (Normally Closed): This terminal is connected to COM by default. When the relay activates, it disconnects from COM. Use COM-NC when you want the appliance to be ON by default and turn OFF when signalled.
Q6. What is PWM and how is it used for motor speed control? (3 marks)
PWM (Pulse Width Modulation) is a technique where a digital pin rapidly switches between HIGH and LOW to simulate an analog voltage level. The ratio of ON time to total period is called the duty cycle.
How it controls speed:
analogWrite(pin, 0)โ 0% duty cycle โ Motor OFFanalogWrite(pin, 127)โ ~50% duty cycle โ Motor at half speedanalogWrite(pin, 255)โ 100% duty cycle โ Motor at full speed
The motor doesn't actually turn on/off rapidly โ its inertia smooths the pulses into a continuous rotation at reduced speed. The L293D Enable pin accepts PWM, making it the perfect speed control input.
Arduino PWM frequency: ~490Hz on most pins, ~980Hz on pins 5 and 6. This frequency is fast enough that the motor runs smoothly without visible stuttering.
Q7. Explain the closed-loop feedback mechanism inside a servo motor. (3 marks)
A servo motor uses a closed-loop feedback system with four components:
- Control Signal (Input): Arduino sends a PWM signal where the pulse width encodes the desired angle (1ms = 0ยฐ, 1.5ms = 90ยฐ, 2ms = 180ยฐ).
- Control Circuit: An internal IC compares the desired angle (from PWM) with the actual angle (from the potentiometer). If they don't match, it drives the DC motor in the correct direction.
- DC Motor + Gear Train: The motor turns through a gear reduction to increase torque and reduce speed. The gears move the output shaft.
- Position Sensor (Potentiometer): A potentiometer attached to the output shaft continuously reports the actual angular position back to the control circuit.
The loop: Control circuit detects error (desired โ actual) โ drives motor โ shaft rotates โ potentiometer updates actual position โ when actual = desired โ motor stops โ servo holds position.
This is why a servo can hold a position under load โ it continuously corrects any deviation.
Q8. What is the function of map() in Arduino? Give an example with potentiometer and servo. (2 marks)
The map() function re-maps (linearly scales) a number from one range to another:
Syntax: map(value, fromLow, fromHigh, toLow, toHigh)
Example: A potentiometer connected to analog pin A0 gives values 0โ1023. A servo needs angles 0โ180.
int potValue = analogRead(A0); // Read: 0โ1023 int angle = map(potValue, 0, 1023, 0, 180); // Convert to 0โ180 myServo.write(angle); // Move servo
If potValue = 512 (knob at centre), map returns: (512/1023) ร 180 โ 90ยฐ โ servo moves to centre position.
Long Answer Questions (5โ8 marks each)
Q1. Explain the complete process of interfacing a DC motor with Arduino using L293D. Include pin diagram, connection table, truth table, and Arduino code for forward, reverse, and speed control. (8 marks)
Answer:
1. L293D Pin Configuration (16-pin DIP)
The L293D is a dual H-bridge motor driver IC with 16 pins:
- Pin 1 (Enable1): Enables Motor A โ connect to Arduino PWM pin for speed control
- Pins 2, 7 (Input1, Input2): Direction control for Motor A
- Pins 3, 6 (Output1, Output2): Connect to Motor A terminals
- Pin 8 (Vs): Motor power supply from battery (6Vโ12V)
- Pin 16 (Vss): Logic power supply from Arduino (+5V)
- Pins 4, 5, 12, 13 (GND): Ground connections (also serve as heat sinks)
- Pin 9 (Enable2), Pins 10, 15 (Input3, Input4), Pins 11, 14 (Output3, Output4): Same as above but for Motor B
2. Connection Table
| Arduino Pin | L293D Pin | Purpose |
|---|---|---|
| Pin 9 (PWM) | Pin 1 (Enable1) | Speed control via PWM |
| Pin 2 | Pin 2 (Input1) | Direction control |
| Pin 3 | Pin 7 (Input2) | Direction control |
| 5V | Pin 16 (Vss) | Logic supply |
| GND | Pins 4,5,12,13 | Common ground |
| โ | Pin 8 (Vs) | Battery + (6Vโ9V) |
Motor wires connect to Pin 3 (Output1) and Pin 6 (Output2). Battery GND must connect to Arduino GND (common ground).
3. Truth Table
| Enable1 | Input1 | Input2 | Motor Action |
|---|---|---|---|
| HIGH/PWM | HIGH | LOW | Forward |
| HIGH/PWM | LOW | HIGH | Reverse |
| HIGH | LOW | LOW | Coast stop |
| LOW | X | X | Motor OFF |
4. Arduino Code
const int enablePin = 9; // PWM for speed
const int in1 = 2; // Direction
const int in2 = 3; // Direction
void setup() {
pinMode(enablePin, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void loop() {
// Forward at 75% speed
analogWrite(enablePin, 191);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(3000);
// Stop
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1000);
// Reverse at 50% speed
analogWrite(enablePin, 127);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
delay(3000);
// Stop
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1000);
}
Key points: Always use external battery for motor power. Enable pin controls speed (PWM 0โ255). Input pins control direction. Common ground is essential between Arduino and battery.
Q2. Design a complete IoT-based smart door lock system using a servo motor and an ultrasonic sensor. Include circuit diagram, connection table, working principle, and full Arduino code. (8 marks)
Answer:
1. System Design
The smart door lock uses an HC-SR04 ultrasonic sensor to detect a person (distance < 20cm) and a servo motor to unlock (rotate to 90ยฐ) the door. After 5 seconds, it automatically locks back (return to 0ยฐ).
2. Components Required
- Arduino Uno
- SG90 Servo Motor
- HC-SR04 Ultrasonic Sensor
- Jumper wires, Breadboard
3. Connection Table
| Component | Pin | Arduino Pin |
|---|---|---|
| HC-SR04 VCC | VCC | 5V |
| HC-SR04 Trig | Trig | Pin 6 |
| HC-SR04 Echo | Echo | Pin 7 |
| HC-SR04 GND | GND | GND |
| Servo Signal | Orange | Pin 9 |
| Servo VCC | Red | 5V |
| Servo GND | Brown | GND |
4. Working Principle
- Ultrasonic sensor continuously measures distance
- If distance < 20cm โ person detected
- Servo rotates from 0ยฐ (locked) to 90ยฐ (unlocked)
- Serial monitor displays "DOOR UNLOCKED"
- After 5 second delay, servo returns to 0ยฐ
- Serial monitor displays "DOOR LOCKED"
5. Arduino Code
#include <Servo.h>
Servo lockServo;
const int trigPin = 6;
const int echoPin = 7;
bool isLocked = true;
void setup() {
lockServo.attach(9);
lockServo.write(0); // Start locked
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
Serial.println("Smart Door Lock Ready");
}
float getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
return duration * 0.034 / 2; // cm
}
void loop() {
float distance = getDistance();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if (distance < 20 && isLocked) {
// Unlock
lockServo.write(90);
isLocked = false;
Serial.println("๐ DOOR UNLOCKED");
delay(5000); // Keep open 5 seconds
// Lock again
lockServo.write(0);
isLocked = true;
Serial.println("๐ DOOR LOCKED");
}
delay(100);
}
Enhancements: Add a keypad for PIN entry, Bluetooth module for phone control, buzzer for alert sounds, or an OLED display to show lock status.
Q3. Compare DC Motor, Servo Motor, and Relay as actuators. Discuss their working principles, advantages, limitations, and suggest appropriate IoT application scenarios for each. (8 marks)
Answer:
1. Comparison Table
| Feature | DC Motor | Servo Motor | Relay |
|---|---|---|---|
| Type | Rotational (continuous) | Rotational (precise angle) | Electrical switch |
| Working | Current through coil in magnetic field โ rotation | DC motor + gears + feedback potentiometer โ closed-loop positioning | Electromagnetic coil pulls switch contacts โ opens/closes circuit |
| Control | Open-loop (no position feedback) | Closed-loop (internal feedback) | Binary ON/OFF |
| Output | Continuous rotation at variable speed | Angular position (0ยฐโ180ยฐ) | Circuit switching (ON or OFF) |
| Driver Needed | Yes โ L293D or similar H-bridge | No โ direct to Arduino + Servo.h library | Relay module with optocoupler (recommended) |
| Power | External battery (6Vโ12V, 100mAโ1A) | Arduino 5V (for 1โ2 servos), external for more | Arduino 5V for coil; separate supply for load |
| Precision | Low โ speed only, no position | High โ 1ยฐ resolution | N/A (binary switching) |
| Cost (India) | โน15โโน40 (hobby motor) | โน60โโน100 (SG90) | โน50โโน100 (1-channel module) |
2. Advantages & Limitations
DC Motor:
- Advantages: Simple, cheap, high RPM, continuous rotation, variable speed via PWM
- Limitations: No position feedback, needs external driver, draws high current, generates electrical noise
Servo Motor:
- Advantages: Precise angle control, built-in feedback, easy to program (Servo.h), low power for small servos, holds position under load
- Limitations: Limited rotation range (180ยฐ), cannot do continuous rotation (standard type), can jitter with noisy power supply, limited torque (small servos)
Relay:
- Advantages: Can switch high-voltage AC (230V), complete electrical isolation with optocoupler, simple ON/OFF control, can control any appliance
- Limitations: Binary only (no speed/position control), mechanical wear over time, audible click, slower switching speed compared to solid-state alternatives, AC wiring requires safety expertise
3. IoT Application Scenarios
| Actuator | Best IoT Application | Why This Actuator? |
|---|---|---|
| DC Motor | Robot car, conveyor belt, fan, water pump | Needs continuous rotation and variable speed |
| Servo Motor | Door lock, gate barrier, camera pan/tilt, robot arm | Needs precise angular positioning and holding |
| Relay | Smart home (lights, fans, pumps), industrial automation | Needs to switch ON/OFF high-power AC appliances from low-power microcontroller |
Conclusion: The choice of actuator depends on the required output: continuous motion โ DC motor, precise positioning โ servo, high-power switching โ relay. Many real-world IoT systems use a combination of all three.
Chapter Summary & Earning Checkpoint
๐ Unit 5 Summary โ Key Takeaways
- Actuators are the output side of IoT โ they convert electrical signals into physical action (motion, switching, sound).
- DC Motors provide continuous rotation but CANNOT be connected directly to Arduino due to current limitations (20mA vs 100mA+).
- L293D is a dual H-bridge motor driver IC that controls 2 motors โ direction via Input pins, speed via Enable pin (PWM), power from external battery.
- Truth table: Enable=HIGH + Input1=HIGH + Input2=LOW โ Forward. Swap inputs โ Reverse. Both LOW โ Coast. Both HIGH โ Brake.
- Servo motors use closed-loop feedback (potentiometer inside) for precise angular positioning (0ยฐโ180ยฐ). Use
Servo.hlibrary withattach(),write(angle). - SG90 is the standard IoT servo: 0ยฐโ180ยฐ, 1.8 kgยทcm torque, 4.8โ6V, costs โน60โโน100.
- Potentiometer + Servo is a classic IoT combo:
analogRead()โmap(0,1023,0,180)โservo.write(). - Relay modules switch high-power loads (AC appliances) using low-power signals. COM-NO for default OFF, COM-NC for default ON.
- Safety first: AC mains (230V India) is lethal โ always use optocoupler isolation and never touch AC wires without supervision.
- A DIY robot car costs โน475 vs โน3,000โโน5,000 for a commercial kit โ and you learn 10ร more building from scratch.
Earning Checkpoint โ What Can You Build & Earn?
| Skill Learned | Tool/Component | Portfolio Piece | Earning Ready? |
|---|---|---|---|
| DC Motor Control | L293D + Arduino | Robot car with direction/speed control | โ Yes โ โน500โโน1,500 workshop kits |
| Servo Control | SG90 + Servo.h | Automated door lock / parking barrier | โ Yes โ IoT project demos |
| Relay Switching | Relay module + Arduino | Smart home light controller | โ Yes โ โน500โโน2,000 installations |
| PWM Speed Control | analogWrite + L293D | Variable-speed fan controller | โ Yes โ add to any project |
| Sensor + Actuator Integration | Pot/Ultrasonic + Servo | Smart parking system | โ Yes โ college project / hackathon |
โ Unit 5 complete. Ready for Unit 6: IoT Communication Protocols!
[QR: Link to EduArtha video tutorial โ Actuators & Motors]