This week focused on understanding and testing output devices. Outputs are components that convert an electrical signal from a microcontroller into a physical, visual, or auditory action. I researched motor types, selected a servo motor, and wrote a program to test its movement as part of my kinetic origami final project.
Add an output device to a microcontroller board you have designed and program it to do something.
Output devices convert the electrical signal from a microcontroller into a physical, visual, or auditory action.
I started by reviewing Ohm's and Kirchhoff's Laws to build a solid foundation before working with output devices.
I then went deeper into output devices and also reviewed my Week 4 — Embedded Systems Map, which helped me recall the different categories of output devices.

I found motors particularly interesting, so I began researching how they operate in more depth. I focused on a few core concepts and started by creating a mind map to understand the different types of actuators available and the situations they are best suited for.
Based on Ohm's and Kirchhoff's laws reviewed in Week 6, connecting a motor directly to a microcontroller pin is not possible. The motor will attempt to draw more current (amps) than the microcontroller pins can supply, which causes the board to overheat and fail.
To prevent this, external components must be used as a bridge. These vary depending on the motor type:for example, MOSFETs for DC motors or dedicated driver ICs for stepper motors. I did another diagram to see wich one is used for each motor.
Since my final project involves a kinetic origami panel that reacts to air quality, I needed to decide between a standard DC motor and a servo for the folding mechanism. Because the design does not require continuous rotation speed control — but instead demands reasonably precise angular movement to fold and unfold the structure — a servo is the better choice.
Connecting a servo is straightforward because it already has an internal controller. It uses three wires.
Power (VCC) — Connected to the 5 V power supply.
Ground (GND) — Connected to the common ground of the circuit.
Signal — Connected directly to a digital PWM pin on the microcontroller.
To connect the servo correctly, I consulted the MG995 datasheet, where I found its pinout.
I also checked the XIAO Pinout to confirm I was using the correct pins before making the connections.
MG995 VCC → PCB PowerMG995 GND → PCB GNDMG995 PWM → PCB Pin D0Once the hardware was connected, I programmed the XIAO RP2350 using Arduino IDE to read the live acceleration values from the MPU6050. The first step was to connect the PCB to Arduino IDE.
I installed the servo Library:
To control the servo, I used Pulse Width Modulation (PWM) to send signals to the motor's internal controller, telling it exactly which angle to move to. The goal of the test code was to make the servo sweep back and forth to simulate the folding motion of the origami.
#include <Servo.h>
Servo miMotor;
int pinServo = 0;
int pinBoton = 7;
void setup() {
miMotor.attach(pinServo);
miMotor.write(0);
pinMode(pinBoton, INPUT_PULLUP);
}
void loop() {
if (digitalRead(pinBoton) == LOW) {
miMotor.write(90);
delay(500);
miMotor.write(180);
delay(500);
miMotor.write(0);
delay(500);
}
delay(50);
}
Code Breakdown
Libraries & Variables
Setup
write() commands generate the correct PWM waveform on that pin.Loop — Button Check
The sweep routine runs only while the button is held. This makes the test repeatable and isolated from the rest of the program.
Sweep Routine
Stability Pause
After uploading the code and connecting the power supply, the servo successfully moved to the programmed angles. Testing this output in isolation from the rest of the project provided the confidence needed to integrate it into the final kinetic structure.
During this week it was very interesting learning about the motors, thanks to this weeks I got to understand the electricity laws better.