SensorsMotorsActuatorsIntegration
On this page

Activity 4.1.1 — Sensors & Motors


Learning Objectives

By the end of this lesson, students will be able to:

  1. Distinguish between digital and analog sensors
  2. Explain how to interface various sensors with digital circuits
  3. Describe different types of motors and their control methods
  4. Use motor driver ICs to interface motors with digital logic
  5. Design simple sensor-motor interface circuits

Vocabulary

Vocabulary (click to expand)
TermDefinition
SensorA device that converts a physical quantity into an electrical signal
ActuatorA device that converts electrical energy into physical motion or other output
Digital SensorA sensor with two output states: HIGH (1) or LOW (0)
Analog SensorA sensor with a continuously variable output voltage
Voltage DividerA circuit that produces an output voltage proportional to input voltage
H-BridgeA circuit that allows control of motor direction by reversing polarity
PWMPulse Width Modulation - rapidly switching to control average power

Part 1: Introduction to Sensors

Sensors are input devices that convert physical phenomena into electrical signals that digital circuits can process.

Two Categories of Sensors

Digital Sensors

Output: HIGH (1) or LOW (0) only

  • Pushbutton — user input
  • Limit switch — position/motion
  • IR break beam — object passage
  • Reed switch — magnetic field
  • Photointerrupter — object detection
Direct to digital circuit
vs

Analog Sensors

Output: continuous voltage range

  • Photocell (LDR) — light detection
  • Thermistor — temperature
  • Potentiometer — position/control
  • Flex sensor — bend detection
  • Force sensor — pressure
Needs ADC / voltage divider

Part 2: Digital Sensors

Common Digital Sensors

SensorSymbolFunction
PushbuttonPressed = HIGH, Released = LOWUser input
Limit SwitchActivated = HIGHDetect position/motion
IR Break BeamBeam broken = HIGHDetect object passage
Magnetic Reed SwitchMagnet present = HIGHDetect magnetic field
PhotointerrupterLight blocked = HIGHObject detection

Digital Sensor Interface

Connecting a pushbutton to a digital circuit:

+5V ──┬── Pull-down resistor (10kΩ) ───▶ Input pin
       │
     ─┴─ Pushbutton
       │
     GND

Pull Resistors:

  • Pull-down resistor: Connects to GND, keeps input LOW when button not pressed
  • Pull-up resistor: Connects to VCC, keeps input HIGH when button not pressed (more common)
+5V ──┬── Pushbutton
       │
     ─┴─ Pull-up resistor (10kΩ) ───▶ Input pin
       │
     GND

Key insight: Pull resistors ensure predictable input states. Without them, the input “floats” and can pick up interference, causing unpredictable behavior.


Part 3: Analog Sensors

Common Analog Sensors

SensorOutput RangeApplication
Photocell (LDR)Dark: high resistance, Light: low resistanceLight detection
ThermistorTemperature-dependent resistanceTemperature sensing
PotentiometerPosition-dependent voltagePosition/volume control
Flex SensorBending increases resistanceBend detection
Force SensorResistance varies with forcePressure/force sensing

Analog Sensor Circuit: Voltage Divider

Most analog sensors change resistance. To convert this to voltage, use a voltage divider:

VCC ──[Fixed R]───[Sensor R]─── GND

           │
           ▼
        Output Voltage

Formula:

Vout = VCC × (R_sensor / (R_fixed + R_sensor))

Example: Photocell Circuit

+5V ──[1kΩ]───[Photocell]─── GND
             │
             ▼
          Vout to ADC or comparator
  • In bright light: Photocell resistance is low (~100Ω), Vout is near 0V
  • In darkness: Photocell resistance is high (~1MΩ), Vout is near 5V

Op-Amp Amplification

For small sensor signals, use an operational amplifier:

         ┌─────────────┐
  V-  ───│             │──▶ Vout
        │    Op-Amp   │    (amplified)
  V+  ───│             │
        └─────────────┘

Non-inverting amplifier: Gain = 1 + (R_feedback / R_input)


Part 4: Motors as Actuators

Types of Motors

Motor TypeControl MethodApplication
DC MotorVoltage/speed, polarity/directionGeneral motion
Servo MotorPWM angle signal (0-180°)Precise positioning
Stepper MotorStep pulses, precise incrementsPrecision control

DC Motors

Characteristics:

  • Speed proportional to applied voltage
  • Direction depends on polarity of applied voltage
  • No built-in position control

Speed Control:

  • Higher voltage = faster speed
  • PWM can simulate variable voltage

Direction Control:

  • Forward: Positive to terminal A, Negative to terminal B
  • Reverse: Negative to terminal A, Positive to terminal B

Servo Motors

Characteristics:

  • Precise angular position (typically 0° to 180°)
  • Internal feedback for position control
  • Controlled by PWM signal

Control Signal:

  • PWM with 20ms period (50 Hz)
  • Pulse width determines angle:
    • 1ms = 0°
    • 1.5ms = 90°
    • 2ms = 180°

Stepper Motors

Characteristics:

  • Moves in precise step increments (e.g., 1.8° per step)
  • Can hold position without power
  • Requires controller to energize coils in sequence

Types:

  • Unipolar: coils have center tap
  • Bipolar: four wires, no center tap (requires H-bridge)

Part 5: Motor Driver ICs

The L293D Dual H-Bridge

The L293D can drive two DC motors or one stepper motor with direction control.

Pinout:

        ┌─────────────┐
  VCC2 -│             │- GND
  1Y   -│             │- 1A
  1A   -│    L293D   │- 1Y
  2A   -│             │- 2Y
  2Y   -│             │- 2A
  VCC1 -│_____________│- GND

Connections:

  • VCC1: Logic power (5V)
  • VCC2: Motor power (up to 36V)
  • 1A, 2A: Control inputs (from digital circuits)
  • 1Y, 2Y: Motor outputs

Truth Table:

1A1Y Output
0Disabled (Hi-Z)
1Enabled (HIGH)

For bidirectional control with enable:

EnableInput AMotor Output
0XDisabled
10Forward
11Reverse

The ULN2003 Darlington Array

The ULN2003 drives stepper motors or high-current loads.

Features:

  • 7 Darlington pairs
  • Can sink up to 500mA per channel
  • Built-in flyback diodes

Typical Stepper Connection:

Arduino ──▶[ULN2003]───▶Stepper Coil
Pin       Channel      Wire

Part 6: Interfacing Sensors with Motors

Example: Light-Activated Motor

Goal: Turn on a fan when it gets too bright

Components:

  • Photocell sensor
  • Comparator circuit
  • L293D motor driver
  • DC fan

Circuit:

+5V ──[Photocell]───[10kΩ]─── GND
         │              │
         ▼              ▼
      Comparator ──────[Input]
         │
         ▼
      L293D Enable ───[HIGH when dark]
         │
         ▼
      Fan Motor

Example: Object Counter with Motor

Goal: Count objects and rotate turntable after each one

Components:

  • IR break beam sensor
  • 74LS90 decade counter
  • L293D driver
  • Stepper motor

Operation:

  1. Object breaks beam
  2. Sensor output goes HIGH
  3. Counter increments
  4. After 10 counts, stepper advances one position

Part 7: Practice Problem

Problem Statement

Design a circuit that:

  1. Uses a limit switch to detect when a door is closed
  2. Turns on an LED when the door is open
  3. Turns on a motor (to close a mechanism) when the door is closed

Components Available:

  • Limit switch (closed = LOW, open = HIGH)
  • LED
  • DC motor
  • L293D motor driver

Draw the circuit and explain the logic.

Show Solution

Circuit Diagram:

+5V ──[Limit Switch]──────▶ Input Pin (with pull-down)
                            │
                           ─┴─ Switch to GND (closed position)
                            │
                            ▼
                    ┌──────────────┐
                    │ Logic        │
                    │ Input        │
                    └──────┬───────┘
                           │
              ┌────────────┼────────────┐
              │            │            │
              ▼            ▼            ▼
          [Inverter]    [LED]      [Motor]
              │            │            │
              ▼            ▼            ▼
           Motor ON    LED ON      OFF when
           when closed  when open   door open
           (door closed           (door open
            signal)               signal inverted)

**Logic:**
- Door open: switch = HIGH → LED ON, Motor OFF
- Door closed: switch = LOW → LED OFF, Motor ON

**Using L293D:**
- Enable pin = switch signal
- Input A = HIGH (for direction)
- When door closes (switch = 0), motor turns

Summary

  • Sensors convert physical phenomena to electrical signals
  • Digital sensors output HIGH or LOW (switches, limit switches, IR beams)
  • Analog sensors output continuous voltage (photocells, thermistors)
  • Use voltage dividers to interface analog sensors with circuits
  • Motors convert electrical energy to motion (DC, servo, stepper)
  • Use motor driver ICs (L293D, ULN2003) to interface motors with digital logic
  • H-bridges enable bidirectional motor control

Key Reminders

  • Always use pull resistors with digital sensors
  • Analog sensors need signal conditioning (voltage dividers, op-amps)
  • Motor drivers protect digital circuits from motor current
  • Use flyback diodes to protect against motor voltage spikes
  • Servo motors use PWM for position control

Custom activity — adapted from PLTW Digital Electronics