Introduction

During this assignment, I worked with several output devices to understand their operation and programming. I used LEDs to produce simple visual indications such as blinking patterns and status notifications. I also interfaced a MAX7219 8×8 LED matrix display to display characters, symbols, scrolling messages, and animations, which helped me understand matrix addressing and display control techniques. In addition, I connected an OLED display using the I²C communication protocol to display text, numbers, and simple graphics with high clarity. I also controlled an SG90 servo motor to perform accurate angular movements, which demonstrated how pulse-width modulation (PWM) is used to control the position of motors.

Individual assignment

Task:

To interface an output device with a microcontroller board and program it to perform a specific function.

Group assignment

Task:

Measure the power consumption of an output device.

Output Devices:

Output devices are hardware components of a computer or microcontroller system that receive data from the system and present it in a form that users can see, hear, or physically experience. They convert digital signals generated by the microcontroller into meaningful visual, audio, or mechanical outputs, allowing the system to communicate information effectively.

Output devices examples:

Components I used for my board are as follows:-

1.LED

About LED

A Light Emitting Diode (LED) is an electronic output device that emits light when electric current flows through it. It is a semiconductor component that converts electrical energy directly into light through a process called electroluminescence. LEDs are widely used in electronic and embedded systems because they consume very little power, generate less heat, respond quickly, and have a long operating life. An LED consists of two terminals: the anode (positive terminal) and the cathode (negative terminal). When the anode is connected to a positive voltage and the cathode is connected to ground, current passes through the semiconductor junction, causing the LED to glow. The color of the light depends on the semiconductor material used during its manufacturing, allowing LEDs to produce colors such as red, green, blue, yellow, white, and orange.

Types of LEDs

  • 1.Indicator LED:- Indicator LEDs are the most widely used LEDs in electronic circuits. They provide visual indications of a device’s operating status, such as power ON, power OFF, charging, or signal activity. These LEDs are available in various colors, including red, green, yellow, blue, and white, and are commonly used in microcontroller and embedded system projects
  • 2.RGB LED:- An RGB (Red, Green, Blue) LED contains three individual LEDs inside a single package. By controlling the brightness of each color using PWM (Pulse Width Modulation), it can produce millions of different colors. RGB LEDs are widely used in decorative lighting, display systems, IoT projects, gaming devices, and creative electronics applications.
  • 3.Infrared (IR) LED:- Infrared LEDs emit infrared light, which is invisible to the human eye. They are mainly used for wireless communication and sensing applications, including television remote controls, obstacle detection, security systems, night vision equipment, and optical communication devices.
  • 4.SMD LED (Surface Mount Device LED):- SMD LEDs are compact LEDs designed to be mounted directly onto the surface of a printed circuit board (PCB). They are highly efficient, consume less space, and provide uniform brightness. SMD LEDs are commonly found in LED strips, televisions, mobile phones, digital displays, automotive lighting, and modern electronic devices.
  • 5.High-Power LED:- High-power LEDs are designed to produce much brighter light than standard indicator LEDs. They are commonly used in high-intensity lighting applications such as LED bulbs, flashlights, floodlights, street lights, and industrial lighting systems. Because they generate significant heat during operation, they usually require a heat sink or cooling mechanism for safe and efficient performance.

diagram of LED

An LED (Light Emitting Diode) has two terminals known as the anode and the cathode. The anode is the positive terminal and is identified by the longer lead, while the cathode is the negative terminal and is identified by the shorter lead. For an LED to operate correctly, the anode must be connected to the positive terminal of the power supply, and the cathode must be connected to ground or the negative terminal. This connection is known as forward bias, which allows electric current to flow through the LED. As current passes through the semiconductor junction, the LED emits light, making it an efficient and widely used output device in electronic and embedded system applications.

Inside an LED, several components work together to produce light efficiently. The outer epoxy lens is a transparent cover that protects the internal parts and helps focus the emitted light. At the center of the LED is the semiconductor die, which contains the PN junction, the region where light is generated. When electric current flows through the PN junction, electrons and holes recombine, releasing energy in the form of visible light through a process called electroluminescence. A reflective cavity (reflector cup) surrounds the semiconductor die and directs the light outward to increase its brightness. The anvil post and lead frame provide mechanical support to the semiconductor chip and create electrical connections to the external leads. Additionally, a flat edge on the LED body is used to identify the cathode (negative terminal), making it easier to connect the LED correctly in an electronic circuit.

2.RGB LED

An RGB LED (Red, Green, Blue Light Emitting Diode) is an electronic output device that combines three LEDs red, green, and blue—inside a single package. By controlling the brightness of each color using Pulse Width Modulation (PWM), the LED can produce millions of different colors. RGB LEDs are widely used in Arduino, ESP32, and other embedded system projects for decorative lighting, status indication, displays, mood lighting, and creative electronic applications. They are energy-efficient, compact, and capable of generating a wide range of colors using a single LED package.

Pin description

  • Red (R): Controls the red LED inside the RGB package. Connect this pin to a microcontroller through a current-limiting resistor.
  • Green (G): Controls the green LED. It is connected to a GPIO pin through a current-limiting resistor.
  • Blue (B): Controls the blue LED. It is connected to a GPIO pin through a current-limiting resistor.
  • Common Pin: Connect the common pin to Ground (GND). The RGB colors are turned on by setting the control pins

Internal structure of an RGB LED

The internal structure of an RGB LED consists of three individual Light Emitting Diodes (LEDs)—Red, Green, and Blue—enclosed within a single transparent package. Each LED is made from a different semiconductor material, allowing it to emit its respective color when electric current passes through it. These three LEDs share a common anode or common cathode terminal, while the remaining three pins control the red, green, and blue LEDs individually. By adjusting the brightness of each LED using Pulse Width Modulation (PWM), different colors can be created through color mixing. The transparent epoxy lens protects the internal components and helps distribute the emitted light evenly, making RGB LEDs suitable for decorative lighting, displays, indicators, and embedded system applications.

The following images show the setup and its successful execution

Here is the code for RGB LED

// ESP32-C3 RGB LED Control using Serial Monitor

const int RED = D2;
const int GREEN = D3;
const int BLUE = D4;

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

  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);

  digitalWrite(RED, LOW);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);

  Serial.println("=== RGB LED Control ===");
  Serial.println("Type a color and press Enter:");
  Serial.println("red");
  Serial.println("green");
  Serial.println("blue");
  Serial.println("yellow");
  Serial.println("cyan");
  Serial.println("magenta");
  Serial.println("white");
  Serial.println("off");
}

void loop() {

  if (Serial.available()) {

    String color = Serial.readStringUntil('\n');
    color.trim();
    color.toLowerCase();

    digitalWrite(RED, LOW);
    digitalWrite(GREEN, LOW);
    digitalWrite(BLUE, LOW);

    if (color == "red") {
      digitalWrite(RED, HIGH);
    }
    else if (color == "green") {
      digitalWrite(GREEN, HIGH);
    }
    else if (color == "blue") {
      digitalWrite(BLUE, HIGH);
    }
    else if (color == "yellow") {
      digitalWrite(RED, HIGH);
      digitalWrite(GREEN, HIGH);
    }
    else if (color == "cyan") {
      digitalWrite(GREEN, HIGH);
      digitalWrite(BLUE, HIGH);
    }
    else if (color == "magenta") {
      digitalWrite(RED, HIGH);
      digitalWrite(BLUE, HIGH);
    }
    else if (color == "white") {
      digitalWrite(RED, HIGH);
      digitalWrite(GREEN, HIGH);
      digitalWrite(BLUE, HIGH);
    }
    else if (color == "off") {
      // All LEDs OFF
    }
    else {
      Serial.println("Invalid Color!");
    }

    Serial.print("Selected Color: ");
    Serial.println(color);
  }
}

3.Servo motor (SG90):-

The SG90 servo motor is a compact, lightweight, and highly efficient actuator commonly used in robotics, automation, and embedded system projects. It is designed to provide precise angular movement, making it ideal for applications that require accurate positioning. The SG90 can typically rotate from 0° to 180° and is widely interfaced with microcontrollers such as Arduino, ESP32, XIAO RP2040, and Raspberry Pi Pico. It operates using Pulse Width Modulation (PWM), where the width of the control pulse determines the angle of the motor shaft. By varying the PWM signal generated by the microcontroller, the servo motor can be positioned accurately at the desired angle.

The SG90 servo motor has three connecting wires. The Brown wire is connected to Ground (GND), the Red wire is connected to the 5V power supply (VCC), and the Orange wire is the PWM control signal connected to the microcontroller. Inside the servo motor are several important components, including a DC motor, gear train, control circuit, and position sensor (potentiometer). The gear train reduces the motor speed while increasing torque, and the position sensor continuously monitors the shaft angle, providing feedback to the control circuit. This closed-loop feedback system enables the servo motor to maintain its position accurately and reliably.

Pin description

  • Brown Wire (GND): Connects to the GND of the microcontroller or power supply. It completes the electrical circuit.
  • Red Wire (VCC): Supplies power to the servo motor. It is usually connected to a 5V power source.
  • Orange Wire (Signal/PWM): Receives the Pulse Width Modulation (PWM) control signal from the microcontroller. The PWM signal determines the angle and position of the servo motor shaft.

Motor structure

The SG90 servo motor has a compact internal structure designed for precise position control. It consists of a DC motor, gear reduction system, control circuit, and potentiometer (position sensor). The DC motor provides the rotation, while the gear system reduces speed and increases torque. The potentiometer continuously senses the shaft position and sends feedback to the control circuit, allowing the servo motor to move accurately and hold the desired angle.

The following images show the setup and its successful execution

Here is the code i used

#include <ESP32Servo.h>

Servo myServo;

const int servoPin = 2;   // Servo signal pin

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

  myServo.setPeriodHertz(50);      // Standard servo frequency
  myServo.attach(servoPin, 500, 2400);

  Serial.println("Servo Test Started");
}

void loop() {

  Serial.println("0 Degree");
  myServo.write(0);
  delay(1000);

  Serial.println("90 Degree");
  myServo.write(90);
  delay(1000);

  Serial.println("180 Degree");
  myServo.write(180);
  delay(1000);

}

4.OLED display

OLED (Organic Light Emitting Diode) Display

An OLED (Organic Light Emitting Diode) display is a compact electronic display used in microcontroller and embedded system projects to show text, numbers, symbols, and graphics. Unlike LCDs, OLED displays do not require a separate backlight because each pixel emits its own light. This results in higher contrast, lower power consumption, and a thinner display. OLED displays are commonly interfaced with microcontrollers such as Arduino, ESP32, and XIAO RP2040 to display sensor readings, system status, menus, and other real-time information.

Pin description

  • VCC (Power Supply): Supplies power to the OLED display. It is connected to the 3.3V or 5V output of the microcontroller, depending on the module specifications.
  • GND (Ground): Connects the OLED display to the ground (GND) of the microcontroller, completing the electrical circuit.
  • SDA (Serial Data): Transfers data and commands from the microcontroller to the OLED display using the I²C communication protocol.
  • SCL (Serial Clock): Provides the clock signal required for I²C communication and synchronizes the data transfer between the microcontroller and the OLED display.

Internal structure of the OLED

The OLED display consists of several thin layers placed between the anode and cathode electrodes. The main layer is the organic semiconductor layer, which emits light when electric current passes through it. Each pixel in the display generates its own light, eliminating the need for a backlight. This allows OLED displays to produce high contrast, deep black colors, and clear images while consuming less power.

Most OLED modules used in embedded systems have four pins: VCC, GND, SDA, and SCL. The VCC pin supplies power, GND provides the ground connection, and SDA and SCL are used for I²C communication with the microcontroller. OLED displays are widely used in Arduino, ESP32, and other embedded projects to display sensor data, menus, system status, digital clocks, weather information, and other real-time data.

The following images show the setup and its successful execution

Here is the code for OLED display

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

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

  Wire.setSDA(D4);
  Wire.setSCL(D5);
  Wire.begin();

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED not found");
    while (1);
  }

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println("Pranay");
  display.display();
}

void loop() {
}

5.MAX7219 LED matrix

Next, I used the MAX7219 LED Matrix to display text, symbols, and simple animations using the ESP32-C3 microcontroller.

The MAX7219 LED Matrix is an 8×8 LED display module controlled by the MAX7219 driver IC, which simplifies the operation of multiple LEDs using only a few microcontroller pins. It consists of 64 LEDs arranged in 8 rows and 8 columns and is commonly used with Arduino, ESP32, XIAO RP2040, and Raspberry Pi Pico to display text, numbers, symbols, scrolling messages, and simple animations. The module communicates through the SPI interface using DIN, CLK, and CS pins, making it easy to interface with microcontrollers. It also supports software-controlled brightness adjustment and allows multiple modules to be connected together to create larger displays. Due to its simple wiring, low power consumption, and versatile display capabilities, the MAX7219 LED Matrix is widely used in digital clocks, scoreboards, information displays, IoT projects, and embedded system applications.

Pin description

  • VCC : Supplies power to the MAX7219 LED matrix module. It is typically connected to the 5V pin of the microcontroller.
  • GND : Connects the module to the ground (GND) of the microcontroller, completing the electrical circuit.
  • DIN : Receives serial data from the microcontroller. Display data and commands are sent to the module through this pin.
  • CS (Chip Select / LOAD): Enables communication with the MAX7219 module. When this pin is activated, the module accepts data from the microcontroller.
  • CLK : Provides the clock signal required for SPI communication and synchronizes the transfer of data.
  • DOUT : Sends data to the next MAX7219 module when multiple LED matrix modules are connected in series (cascaded).
The following images show the setup and its successful execution

Here is the code for MAX7219 LED matrix

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 1

#define DATA_PIN D10
#define CLK_PIN  D8
#define CS_PIN   D9

MD_Parola display = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

void setup() {
  display.begin();
  display.setIntensity(5);
  display.displayClear();
  display.displayText("ATHARV", PA_CENTER, 100, 1000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
}

void loop() {
  if (display.displayAnimate()) {
    display.displayReset();
  }
}

6.LCD Display

LCD (Liquid Crystal Display) is an electronic output device used to display text, numbers, and simple symbols in electronic and embedded system projects. It works by controlling liquid crystals to form visible characters with the help of a backlight. LCD displays are widely used with microcontrollers such as Arduino, ESP32, and XIAO RP2040 to display sensor readings, system status, menus, and other information. They are popular because they consume low power, are easy to interface, and provide a clear and readable display.

Pin description

  • VCC: Supplies power to the LCD module. It is connected to the 5V pin of the microcontroller.
  • GND: Connects the LCD module to the GND of the microcontroller, completing the electrical circuit.
  • SDA : Transfers data and commands from the microcontroller to the LCD using the I²C communication protocol.
  • SCL : Provides the clock signal required for I²C communication and synchronizes data transfer between the microcontroller and the LCD.

Internal structure of LCD

The internal structure of an LCD (Liquid Crystal Display) consists of several thin layers that work together to produce visible characters or images. It includes a backlight (or reflective layer) that provides illumination, followed by a rear polarizing filter. A layer of glass substrate contains transparent electrodes made of Indium Tin Oxide (ITO), which apply electrical signals to the liquid crystals. The liquid crystal layer is sandwiched between two glass plates and changes its orientation when voltage is applied, controlling the amount of light passing through. Above this is another glass substrate with transparent electrodes, followed by a front polarizing filter. In color LCDs, a color filter (red, green, and blue sub-pixels) is added to produce different colors. Finally, a protective outer layer covers the display. The display is controlled by an LCD driver/controller IC, which receives data from the microcontroller and activates the required pixels to display characters, numbers, or graphics.

The following images show the setup and its successful execution

Here Is The For LCD Display

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);   // Change to 0x3F if your LCD uses that address

void setup() {
  Wire.setSDA(D4);
  Wire.setSCL(D5);
  Wire.begin();

  lcd.init();
  lcd.backlight();

  // Display "Pranay" in the center of the first line
  lcd.setCursor(5, 0);
  lcd.print("Pranay");
}

void loop() {
  // Nothing to do
}

Objective of group assignment

Measure the power consumption of an output device

In this assignment, we learned about output devices used in electronic systems. We started a group assignment to study different output devices such as LEDs, OLED displays, and BO motors. During this activity, we tested how these devices work by interfacing them with a microcontroller and observed their outputs. We also measured and compared the power consumption of each component to understand their efficiency and operating characteristics.

1) We calculated the power consumption of BO motor

We used a simple program to operate the BO motor. The code was uploaded to turn the BO motor ON. The motor was connected to a variable power supply, which provided the required operating voltage. When the motor was switched ON, the display on the power supply showed the voltage and current consumed by the motor. By observing these values, we were able to measure the BO motor’s power consumption during operation and understand its electrical characteristics.

Components used

  • Yellow BO Motor (Geared DC Motor)
  • DC Power Supply
  • Digital Multimeter
  • Motor Driver Module
  • Jumper Wires
  • Breadboard

the BO motor takes 07.03 V and 0.147 A current.
To calculate power, we use the formula: 𝑃=𝑉×𝐼
V=07.03V, 𝐼=0.147A,
So, 𝑃=07.03×0.147
P=1.0334W
Power consumed by BO motor = 1.0334 W

2) We calculated the power consumption of Stepper motor


To test the stepper motor, we uploaded a simple program to the microcontroller. The stepper motor was connected to a variable power supply, which supplied the required voltage for its operation. After running the program, the motor started rotating according to the programmed instructions. During the test, the power supply display showed the voltage and current used by the motor. These readings helped us analyze the stepper motor’s power consumption and understand its operating performance.

the Stepper motor takes 12.06 V and 0.215 A current.
To calculate power, we use the formula: 𝑃=𝑉×𝐼
V=12.06V, 𝐼=0.215A,
So, 𝑃=12.06×0.215
P=2.5929W
Power consumed by BO motor = 2.5929 W

Conclusion

Through this group assignment, we learned how to measure and calculate the power consumption of an output device. By analyzing the voltage and current requirements of the Yellow BO Motor, we understood the importance of power measurement while selecting components for embedded systems and robotic applications.

This experiment improved our practical knowledge about electrical characteristics of output devices and their integration into real-world electronic systems.

Week Summary

This week focused on understanding output devices and their interfacing with embedded systems. I learned the working principles, internal structures, and applications of different output devices such as LED, RGB LED, buzzer, displays, motors, and relay modules. I interfaced these devices with the Seeed Studio XIAO ESP32-C3 microcontroller and programmed them using Arduino IDE. Through practical experiments, I understood how microcontrollers control output devices using digital signals, PWM, and I2C communication. In the group assignment, we measured the voltage, current, and power consumption of a Yellow BO Motor to understand its electrical characteristics. This activity improved my knowledge of embedded system control, device interfacing, and power analysis.