Output device
Task:-
Group assignment:
Measure the power consumption of an output device.
Individual assignments:
Add an output device to a microcontroller board you've designed and program it to do something.
Output devices
anything that takes signals from a microcontroller and produces a visible or physical result.
Outputs devices eg:
Actuator
type of output device that creates movement.
It converts electrical energy >> mechanical motion.
“muscle” of the system.
Actuators eg:
- Servo motor (moves to angle like 0-180°; 0 -360°)
- DC motor (continuous rotation)
- Stepper motor (precise steps)
- Linear actuator (push/pull motion)
Drivers
It is a circuit or component that allows a microcontroller to safely control devices that require more power.
Drivers can be built using components like transistors, MOSFETs, or circuits like H-bridges, depending on the application.
AI Prompt Used:
i want a sticky note pad section in my website for my output devices explanation.
it is only for my notes (not for users), so it should be static.
the notes should look like real sticky notes with different colors, slight rotation. Give me html and css for this.
PWM - Pulse Width Modulation
PWM
is a technique to control power by switching a signal ON and OFF rapidly. It is used to control the brightness of LEDs, speed of motors, and many more.
duty cycle
% of time the signal is ON in one cycle. for eg: 50% duty cycle → ON half the time, other half off
DC=(how long the signal stays ON in one cycle / total time of one cycle )x 100%
Source: Equation
Average voltage
calculation:
Because the device cannot follow the rapid ON/OFF switching, so it responds to the average energy over time.
for example, with a 50% duty cycle, the average voltage is:
Vpeak = 5V
Vavg = 5V x 0.5 =2.5V which results in:
- LED looks dimmer
- Motor runs slower
Frequency
how many times the signal completes a full ON/OFF cycle in one second.
- Unit = Hertz (Hz)
- 1 Hz = 1 cycle per second
Servo motor
A servo motor is a precision motor with a closed-loop feedback system. It rotates, checks its position, and keeps adjusting until it reaches the exact angle or position.
It is mainly used to move something to a specific angle or position accurately.
Refer this for learning about Servo Motor Working Principle.
Power consumption of servo motor
How to choose right servo motor
For choosing the right servo motor mainly depends on the torque required, along with speed and precision based on your application.
Torque
the strength needed to rotate or move something, and it depends on the weight and distance from the pivot.
T=FxD , where:
- T (Torque) = turning force
- F (Force) = how much weight/load you are moving
- d (Distance) = how far the load is from the center (pivot)

Source: YouTube Video
As distance increases, torque required increases — so lifting capacity decreases
Servo Motor Specifications
- Control Signal: PWM (Pulse Width Modulation)
- Pulse Frequency: 50Hz (20ms period)
- Position Range: 0° to 180° (standard servos)
- Power Supply: 4.8V - 6V
- Control Pulse:
- 1 ms - 0°
- 1.5 ms - 90°
- 2 ms - 180°
Source: CircuitDigest
MG90S 180° Position Control Servo Motor

Source: MakerSelectronics KitsGuru makemanyrobots
Download MG90S Servo Motor Datasheet
MG90S Servo Motor Specifications
13.4 g
22.5 x 12 x 35.5 mm
4.8V - 6V
Power required to run the motor.1.8 kgf·cm (4.8V)
2.2 kgf·cm (6V)
0.10 s / 60° (4.8V)
0.08 s / 60° (6V)
PWM (50Hz, 20ms period)
The motor is controlled using PWM signals.0° - 180°
Metal Gear
More durable than plastic.Where I am using it:
I am using the MG90S servo motor in my puppet mechanism, where strings are attached to the motor shaft to control the movement of the puppet's hands and legs.
Why I chose this motor:
The MG90S has metal gears, so it is stronger and lasts longer than plastic ones.
Since the puppet uses strings that keep pulling, a strong motor is needed.
It also gives precise movement, which helps control the puppet easily.
DFPlayer - Mini MP3 Player

Source: DFPlayer wiki DFRobot
DFPlayer Datasheet
JQ6500 - MP3 Module

Source: gogotronics robu
JQ6500 Datasheet
Component and Design Considerations
I selected the MG90S servo motor and the DFPlayer Mini (DFR0299) as the output devices for this system.
The servo motor enables the movement of the puppets, while the DFPlayer module, along with a speaker, plays stories and music.
Together, these components act as actuators to create an interactive storytelling experience.
The modules and components were not soldered; instead, pin headers and sockets were used to allow easy plugging, testing, and replacement.
Socket for development board
Qty.1
Module_XIAO_
Generic_SocketSMD
Pinheader for servo motor
Qty.1
PinHeader_02x03_
P2.54mm_Vertical_SMD
Resistor
Qty.1
R_1206 499ohm
led
Qty.1
LED_1206
Capacitor
Qty.1
C_1206 10uf
Socket for DFP player
Qty.2
Conn_01x08_Socket
Connector for speaker
Qty.1
S2B-PH-SM4-TB
Ground(GND)
Qty.8
GND
VCC
Qty.7
+5v
Powerflag
Qty.2
PWR_FLAG
PCB designing

Download schematics

I connected UART communication pins incorrectly. Although I was aware that the TX and RX pins of the DFPlayer should be connected to the RX and TX pins of the XIAO RP2040 respectively,
I accidentally swapped the connections on both the DFPlayer and the XIAO RP2040 during PCB design.
What did i do is: the TX pins were connected to TX and RX to RX, which resulted into a communication failure between the microcontroller and the DFPlayer module.

To fix this issue, the connections were corrected by rerouting the signals using insulated jumper wires(copper). The development board's TX pin was connected to the module's RX pin, and the development board's RX pin was connected to the module's TX pin.


Programming and Testing
void setup() {
pinMode(D0, OUTPUT);
}
void loop() {
digitalWrite(D0, HIGH);
delay(1000);
digitalWrite(D0, LOW);
delay(1000);
}
Chatgpt AI
Prompt Used:
I have designed a pcb which has xiao rp2040, led connected to d0 >> resistor 499ohm,
capacitor 10uf, servo motor connected to d1 give program to rotate it in 180 degree.
#include <Servo.h>
Servo myServo;
void setup() {
myServo.attach(D1);
}
void loop() {
myServo.write(0);
delay(2000);
myServo.write(90);
delay(2000);
myServo.write(180);
delay(2000);
}
For mp3, i downloaded some youtube videos link and converted them to mp3 using online converter, then i trimmed the music to get the required part using audio cutter.
Youtube Source: new dogy itsy bee and the royal flea ക്ളിഞ്ഞോ പ്ലിങ്ഞ്ഞോ SOUNDS!! - BLENDER 2.9 ( Software)
Connect the SD card to laptop and copy the converted mp3 files to the SD card. The mp3 files should be named as 0001.mp3, 0002.mp3, 0000.mp3 inside the SD card.
For installing the dfplayer library in arduino ide; download the zip file from github.
In arduino IDE, sketch >> include library >> add .zip library; add the downloaded zip file. Once it's installed, it will show library installed in output.

Chatgpt AI
Prompt Used:
I have designed a PCB which has XIAO RP2040, LED connected to D0 through a 499ohm resistor and 10uF capacitor,
a servo motor connected to D1, and a DFPlayer Mini module
with the speaker connected to SPK1 and SPK2 and the BUSY pin connected to D8.
Give a program to play 0001.mp3 from the SD card using DFPlayer.
It should automatically start playing when powered on, set the volume, and show an error if the module is not detected.
#include <DFRobotDFPlayerMini.h>
DFRobotDFPlayerMini df;
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
delay(2000);
Serial.println("Initializing DFPlayer...");
if (!df.begin(Serial1)) {
Serial.println("DFPlayer ERROR");
while(true);
}
Serial.println("DFPlayer OK");
df.volume(20);
delay(500);
df.play(1); // plays 0001.mp3
}
void loop() {}
#include <DFRobotDFPlayerMini.h>
DFRobotDFPlayerMini df;
bool isPaused = false;
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
delay(2000);
Serial.println("Initializing DFPlayer...");
if (!df.begin(Serial1)) {
Serial.println("DFPlayer ERROR");
while(true);
}
Serial.println("DFPlayer Ready!");
df.volume(20);
df.play(1);
Serial.println("Controls:");
Serial.println("SPACE = Pause/Resume");
Serial.println("A = Previous");
Serial.println("D = Next");
Serial.println("W = Volume Up");
Serial.println("S = Volume Down");
}
void loop() {
if (Serial.available()) {
char key = Serial.read();
// SPACE → Pause / Resume
if (key == ' ') {
if (isPaused) {
df.start();
Serial.println("Resume");
} else {
df.pause();
Serial.println("Pause");
}
isPaused = !isPaused;
}
// A → Previous
else if (key == 'a') {
df.previous();
Serial.println("Previous track");
}
// D → Next
else if (key == 'd') {
df.next();
Serial.println("Next track");
}
// W → Volume Up
else if (key == 'w') {
df.volumeUp();
Serial.println("Volume Up");
}
// S → Volume Down
else if (key == 's') {
df.volumeDown();
Serial.println("Volume Down");
}
}
}