Introduction

Week – Output Devices

Introduction

This week, I learned about Output Devices and their role in embedded systems and electronics. We studied different output devices such as LED, LCD Display, OLED Display, 7-Segment Display, DC Motor, Servo Motor, Buzzer, Relay, Solenoid Lock, and Vibration Motor. I learned how each device works, its applications, and how it interfaces with a microcontroller such as Arduino or ESP32.

After understanding the working principle of each output device, we measured and studied their operating voltage, current consumption, and power requirements. This helped me understand how to select an appropriate power supply and safely interface output devices in electronic circuits. Overall, this week’s activities improved my understanding of output devices and their practical use in embedded system projects.

Output Devices

Output devices are electronic components that receive signals from a microcontroller or electronic circuit and convert them into a visible, audible, or physical action. They are used to display information, provide alerts, create movement, or control external devices. In embedded systems, output devices respond to processed input data and perform the required task.

Common examples of output devices

  • LED (Light Emitting Diode) – Produces light to indicate system status.
  • Buzzer – Generates sound for alarms or notifications.
  • LCD/OLED Display – Shows text, numbers, or graphics.
  • 7-Segment Display – Displays numerical digits.
  • DC Motor – Provides continuous rotational movement.
  • Servo Motor – Moves to a specific angle with precision.
  • Relay – Controls high-voltage or high-current electrical devices.
  • Solenoid Lock – Locks or unlocks doors electronically.
  • Vibration Motor – Produces vibration for alerts or feedback.
  • LED Matrix Display – Displays characters, symbols, and animations.

Individual assignment

Task

Introduction

In this week’s individual assignment, I interfaced and tested various output devices with the ESP32-C3 microcontroller to understand their working principles and practical applications. The output devices used in this assignment were LED, 16×2 LCD, OLED Display, Buzzer, DC Motor, Relay Module, and Servo Motor.

Each device was connected to the ESP32-C3, programmed using the Arduino IDE, and tested to verify its operation. Through these experiments, I learned how to control different types of output devices using GPIO pins, generate digital output signals, and understand the voltage and power requirements of each device. This assignment helped me gain hands-on experience in interfacing output devices with the ESP32-C3 and applying them in embedded system projects.

1. LED (Light Emitting Diode)

The LED (Light Emitting Diode) is one of the most commonly used output devices in electronics. It emits light when current flows through it and is used as a visual indicator in electronic circuits. In this assignment, I interfaced an LED with the ESP32-C3 and controlled it using a GPIO pin. I programmed the ESP32-C3 to turn the LED ON and OFF with a time delay, demonstrating basic digital output control. This experiment helped me understand LED interfacing, GPIO pin control, and the importance of using a current-limiting resistor to protect the LED.

Types of LEDs

  1. Standard LED – Available in different colors such as red, green, blue, yellow, and white. Used for status indication and basic lighting.
  2. RGB LED – Contains red, green, and blue LEDs in a single package. By mixing these colors, it can produce many different colors.
  3. SMD LED (Surface Mount Device) – A compact LED designed for mounting directly onto PCBs. Commonly used in modern electronic devices.
  4. High-Power LED – Produces much brighter light than a standard LED and is used in flashlights, streetlights, and industrial lighting. It requires proper heat dissipation.
  5. Infrared (IR) LED – Emits infrared light, which is invisible to the human eye. Used in remote controls, IR sensors, and communication systems.
  6. Addressable RGB LED (WS2812B / NeoPixel) – Each LED can be individually controlled to display different colors and animations. Widely used in decorative lighting and embedded system projects.

diagram of LED

In this individual task, I interfaced an LED with the Seeed Studio XIAO ESP32-C3 microcontroller. The LED was connected to one of the digital output pins through a current-limiting resistor. I wrote and uploaded a program to control the LED, making it blink at regular intervals. This activity helped me understand how a microcontroller controls an output device using digital signals. I also observed the LED’s operation and verified that the circuit and program worked correctly.

code for blinking LED

// LED Blink using XIAO ESP32-C3const int ledPin = D10; // LED connected to D10void setup() {pinMode(ledPin, OUTPUT);}void loop() {digitalWrite(ledPin, HIGH); // LED ONdelay(1000); // Wait 1 seconddigitalWrite(ledPin, LOW); // LED OFFdelay(1000); // Wait 1 second}

2.RGB

An RGB LED (Red, Green, Blue Light Emitting Diode) is an electronic component that contains three LEDs (Red, Green, and Blue) inside a single package. By controlling the brightness of each color, the RGB LED can produce millions of different colors.

Pin Configuration

PinDescription
Long PinCommon Anode or Common Cathode
RRed LED Control
GGreen LED Control
BBlue LED Control

code for RGB

#define RED_PIN    2#define GREEN_PIN  3#define BLUE_PIN   4void setup() {  pinMode(RED_PIN, OUTPUT);  pinMode(GREEN_PIN, OUTPUT);  pinMode(BLUE_PIN, OUTPUT);}void loop() {  // Red  digitalWrite(RED_PIN, HIGH);  digitalWrite(GREEN_PIN, LOW);  digitalWrite(BLUE_PIN, LOW);  delay(1000);  // Green  digitalWrite(RED_PIN, LOW);  digitalWrite(GREEN_PIN, HIGH);  digitalWrite(BLUE_PIN, LOW);  delay(1000);  // Blue  digitalWrite(RED_PIN, LOW);  digitalWrite(GREEN_PIN, LOW);  digitalWrite(BLUE_PIN, HIGH);  delay(1000);  // Yellow (Red + Green)  digitalWrite(RED_PIN, HIGH);  digitalWrite(GREEN_PIN, HIGH);  digitalWrite(BLUE_PIN, LOW);  delay(1000);  // Cyan (Green + Blue)  digitalWrite(RED_PIN, LOW);  digitalWrite(GREEN_PIN, HIGH);  digitalWrite(BLUE_PIN, HIGH);  delay(1000);  // Magenta (Red + Blue)  digitalWrite(RED_PIN, HIGH);  digitalWrite(GREEN_PIN, LOW);  digitalWrite(BLUE_PIN, HIGH);  delay(1000);  // White (All ON)  digitalWrite(RED_PIN, HIGH);  digitalWrite(GREEN_PIN, HIGH);  digitalWrite(BLUE_PIN, HIGH);  delay(1000);  // OFF  digitalWrite(RED_PIN, LOW);  digitalWrite(GREEN_PIN, LOW);  digitalWrite(BLUE_PIN, LOW);  delay(1000);}

3. Servo Motor (SG90)

The SG90 Servo Motor is a small, lightweight, and high-precision output device used to control angular position. Unlike a DC motor, a servo motor rotates to a specific angle based on the control signal received from a microcontroller. It is commonly used in robotics, automation, camera pan-tilt systems, robotic arms, and smart door lock projects.

In this assignment, I interfaced the SG90 Servo Motor with the ESP32-C3 and controlled its rotation using PWM (Pulse Width Modulation) signals. The servo was programmed to rotate to different angles such as 0°, 90°, and 180°, demonstrating accurate position control. This experiment helped me understand servo motor interfacing, PWM signal generation, and position control using the ESP32-C3.

Pin Configuration

  • Brown – GND
  • Red – VCC (5V)
  • Orange – Signal (PWM)

main types of servo motors:

  1. Positional Rotation Servo
    • Rotates to a fixed angle (typically 0°–180°).
    • Most common type used in electronics and robotics.
    • Example: SG90, MG90S, MG996R.
  2. Continuous Rotation Servo
    • Rotates continuously in clockwise or counterclockwise direction.
    • Speed and direction are controlled using PWM.
    • Used in robot wheels and conveyor systems.
  3. Linear Servo
    • Produces linear (straight-line) motion instead of rotational motion.
    • Used in actuators, RC aircraft, and industrial automation.

Motor structure

code for servo motor

#include <ESP32Servo.h>Servo myServo;void setup() {myServo.attach(2); // Signal pin connected to GPIO2}void loop() {myServo.write(0);delay(1000);myServo.write(90);delay(1000);myServo.write(180);delay(1000);}

4. MAX7219 LED Matrix (8×8)

The MAX7219 LED Matrix is an output display module that consists of an 8×8 LED matrix controlled by the MAX7219 driver IC. The driver IC simplifies communication by allowing the microcontroller to control all 64 LEDs using only three signal pins. It is commonly used to display text, numbers, symbols, and simple animations.

In this assignment, I interfaced the MAX7219 8×8 LED Matrix with the ESP32-C3 and displayed scrolling text and patterns. This experiment helped me understand serial communication (SPI), LED matrix control, and display programming using the ESP32-C3.

Pin Configuration

  • VCC – 5 V Power Supply
  • GND – Ground
  • DIN – Serial Data Input
  • CS (LOAD) – Chip Select
  • CLK – Clock Signal

Internal Structure

The MAX7219 LED Matrix is made up of an 8×8 LED matrix and the MAX7219 driver IC. The driver IC controls all 64 LEDs using only three communication pins (DIN, CLK, and CS), reducing the number of GPIO pins required from the microcontroller. Inside the MAX7219, a Serial Input Register receives data from the ESP32 or Arduino, a Display RAM stores the display data, and Row (Digit) Drivers and Column (Segment) Drivers continuously scan the LED matrix using multiplexing. This high-speed scanning makes the displayed text or patterns appear continuously visible. The MAX7219 also includes brightness control and current limiting, making it efficient and easy to interface with microcontrollers.

code forled matrix

#include <MD_MAX72xx.h>#include <SPI.h>#define HARDWARE_TYPE MD_MAX72XX::FC16_HW#define MAX_DEVICES 1#define DATA_PIN 2#define CLK_PIN 4#define CS_PIN 3MD_MAX72XX mx(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);byte sadFace[8] = {B00111100,B01000010,B10100101,B10000001,B10011001,B10100101,B01000010,B00111100};void setup() {mx.begin();mx.control(MD_MAX72XX::INTENSITY, 8);mx.clear();for (int row = 0; row < 8; row++) {for (int col = 0; col < 8; col++) {bool pixel = bitRead(sadFace[row], 7 - col);mx.setPoint(row, col, pixel);}}}void loop() {}

5. Buzzer

A buzzer is an electronic output device that converts electrical signals into sound. It is commonly used in embedded systems to produce beep sounds for alerts, alarms, notifications, and warnings. A microcontroller controls the buzzer by sending digital signals to turn it ON or OFF.

In this study, I learned about the buzzer’s working principle, internal structure, pin configuration, operating voltage, current consumption, and applications. I also interfaced the buzzer with the Seeed Studio XIAO ESP32-C3 and programmed it to generate a beep sound.

1. Active Buzzer

Has a built-in oscillator.

Produces a beep sound when DC power is applied.

Easy to use because it only needs an ON/OFF signal from the microcontroller.

Commonly used in alarms, timers, and simple notification systems.

2. Passive Buzzer

Does not have a built-in oscillator.

Requires a PWM (Pulse Width Modulation) signal from the microcontroller to produce sound.

Can generate different tones and melodies by changing the frequency.

Commonly used in music players, electronic toys, and projects that require different sound frequencies.

Individual Task – Interfacing Buzzer with XIAO ESP32-C3

In this individual task, I interfaced a buzzer with the Seeed Studio XIAO ESP32-C3 microcontroller. The buzzer was connected to a digital output pin, and I wrote and uploaded a program to generate a beep sound by turning the buzzer ON and OFF at regular intervals.

This activity helped me understand how a microcontroller controls an output device using digital signals. I also learned about the buzzer’s pin connections, working principle, and how it can be used to provide alerts, alarms, and notifications in embedded system applications.

Active Buzzer Pin Configuration

Pin Description

+ (VCC) Power Supply (3.3V–5V)

– (GND) Ground

code for buzzer

const int buzzerPin = D10; // Connect buzzer signal pin to D10void setup() {pinMode(buzzerPin, OUTPUT);}void loop() {digitalWrite(buzzerPin, HIGH); // Buzzer ONdelay(500);digitalWrite(buzzerPin, LOW); // Buzzer OFFdelay(500);}

6.Displays

A display is an electronic output device used to show information such as text, numbers, symbols, and graphics. It helps users view the data generated by a microcontroller or electronic system. Displays are widely used in embedded systems to show sensor readings, system status, menus, and messages.

In this study, I learned about different types of displays, their working principle, internal structure, pin configuration, operating voltage, and applications. I also studied how displays can be interfaced with a microcontroller to present information clearly and efficiently.

LCD Display

Individual Task – Interfacing LCD Display with XIAO ESP32-C3

In this individual task, I interfaced a 16×2 LCD display with the Seeed Studio XIAO ESP32-C3 microcontroller. The LCD was connected using the I²C interface, which requires only four connections: VCC, GND, SDA, and SCL. I wrote and uploaded a program to display text on the LCD screen.

This activity helped me understand how a microcontroller communicates with a display to show information. I also learned the I²C communication protocol, LCD pin connections, and how to display custom messages using the Arduino IDE.

16×2 LCD (I²C) Pin Configuration

PinDescription
GNDGround
VCCPower Supply (5V)
SDAI²C Data
SCLI²C Clock

code for lcd display

#include <Wire.h>#include <LiquidCrystal_I2C.h>// LCD I2C address (usually 0x27 or 0x3F)LiquidCrystal_I2C lcd(0x27, 16, 2);void setup() {Wire.begin(); // Initialize I2Clcd.init(); // Initialize LCDlcd.backlight(); // Turn on backlightlcd.setCursor(0, 0);lcd.print("LCD");lcd.setCursor(0, 1);lcd.print("XIAO ESPRP2040");}void loop() {// Nothing to repeat}

OLED Display

An OLED (Organic Light Emitting Diode) Display is a compact, low-power output device used to display text, graphics, icons, and images. Unlike LCDs, OLED displays do not require a backlight because each pixel emits its own light. The 0.96-inch SSD1306 OLED Display is widely used with Arduino, ESP32, and other microcontrollers.

Individual Task – Interfacing OLED Display with XIAO ESP32-C3

In this individual task, I interfaced a 0.96-inch OLED Display with the Seeed Studio XIAO ESP32-C3 microcontroller using the I²C communication protocol. The OLED display was connected using four pins: VCC, GND, SDA, and SCL. I wrote and uploaded a program to display text on the OLED screen.

This activity helped me understand how a microcontroller communicates with an OLED display using the I²C protocol. I also learned about the OLED display’s working principle, pin connections, and how it can be used to display text, numbers, symbols, and graphics in embedded system applications.

OLED Display Pin Configuration

PinDescription
GNDGround
VCCPower Supply (3.3V–5V)
SCLI²C Clock
SDAI²C Data

code for oled display

#include <Wire.h>#include <Adafruit_GFX.h>#include <Adafruit_SSD1306.h>#define SCREEN_WIDTH 128#define SCREEN_HEIGHT 64#define OLED_RESET -1Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);void setup() {Wire.begin();if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {while (true);}display.clearDisplay();display.setTextSize(2);display.setTextColor(SSD1306_WHITE);display.setCursor(10, 20);display.println("Dayanu");display.display();}void loop() {}

7-Segment Display

7-Segment Display is an electronic output device used to display numbers (0–9). It consists of seven LED segments (a–g) arranged in the shape of the number 8. By turning different segments ON or OFF, different digits can be displayed. Some displays also include a Decimal Point (DP).

Individual Task – Interfacing 7-Segment Display with XIAO ESP32-C3

In this individual task, I interfaced a 7-segment display with the Seeed Studio XIAO ESP32-C3 microcontroller. The display was connected to the digital output pins of the microcontroller, and I wrote and uploaded a program to display numbers on the 7-segment display.

This activity helped me understand how individual LED segments are controlled to form numerical digits. I also learned about the working principle, pin connections, and applications of a 7-segment display in embedded system projects.

code for 7 segment display

// Segment pins: a, b, c, d, e, f, gconst int segPins[7] = {D0, D1, D2, D3, D4, D5, D6};// Digit 0byte digit0[7] = {1,1,1,1,1,1,0};void setup() {for (int i = 0; i < 7; i++) {pinMode(segPins[i], OUTPUT);}}void loop() {// Display digit 0for (int i = 0; i < 7; i++) {digitalWrite(segPins[i], digit0[i]);}}

Group assignment

BO motor (Battery Operated motor )

A BO (Battery Operated) motor is a small DC motor used in robotics and electronic projects. It works by converting electrical energy from a battery into mechanical movement. BO motors are commonly used in toy cars, robots, and small vehicles because they are easy to use, lightweight, and inexpensive. They usually operate on 3V to 12V and provide enough power to move small wheels. BO motors are popular among students for science and engineering projects because they are simple, reliable, and easy to connect.

BO Motor Pin Configuration

  BO DC Motor

┌─────────────┐

│             │

│             │

└─────────────┘

   |       |

  Pin 1   Pin 2

   (+)     (-)

 BO DC motor using an Arduino Uno and L298N Motor Driver

In my individual assignment, I controlled a BO DC motor using an Arduino Uno. The main objective of this project was to understand how a DC motor can be interfaced and controlled using a microcontroller. I connected the Arduino Uno to a motor driver module, which safely supplied power to the BO motor based on the Arduino’s control signals. I wrote and uploaded an Arduino program to control the motor’s operation, including starting, stopping, and changing its direction of rotation. Through this assignment, I gained practical experience in circuit connections, Arduino programming, motor control, and troubleshooting hardware and software issues. This project helped me develop a better understanding of embedded systems and their applications in robotics and automation.

Arduino Uno ↔ L298N Motor Driver Connections

Arduino Uno PinL298N PinPurpose
D8IN1Motor direction control
D9IN2Motor direction control
D10 (PWM)ENAMotor speed control (PWM)
GNDGNDCommon ground
5V (if required for logic)5VLogic power (depends on your module’s jumper settings)
#define ENA 5#define IN1 8#define IN2 9void setup() {  pinMode(ENA, OUTPUT);  pinMode(IN1, OUTPUT);  pinMode(IN2, OUTPUT);}void loop() {  // Forward  analogWrite(ENA, 200);   // Speed (0–255)  digitalWrite(IN1, HIGH);  digitalWrite(IN2, LOW);  delay(3000);  // Stop  analogWrite(ENA, 0);  delay(1000);  // Reverse  analogWrite(ENA, 200);  digitalWrite(IN1, LOW);  digitalWrite(IN2, HIGH);  delay(3000);  // Stop  analogWrite(ENA, 0);  delay(1000);}