Introduction

For this week’s assignment, I used a micro servo motor as an output device, connected to the Seeed Studio XIAO RP2040 microcontroller. Servo motors are commonly used for controlling position, making them ideal for robotics, mechanisms, and interactive movement.

Components Used

  • Seeed Studio XIAO RP2040
  • SG90 Micro Servo Motor
  • External 5V power supply (recommended for stable performance)
  • Breadboard and jumper wires

About Servo Motors

Servo motors rotate to specific angles based on the width of PWM signals. They have three main connections:

  • GND: Connects to ground
  • VCC: Power supply (typically 5V)
  • Signal: PWM signal from microcontroller

Wiring

I connected the SG90 servo motor to the XIAO RP2040 as follows:

  • Servo GND → GND (XIAO)
  • Servo VCC → 5V (external power recommended)
  • Servo Signal → D2 (physical pin 4 on XIAO RP2040)

Note: I used a common GND between the XIAO and the servo power supply to ensure stable signal operation.

Programming the Servo

I used the Arduino IDE to program the XIAO RP2040. The standard Servo.h library works with the RP2040 core.

Arduino Code

#include <Servo.h>
											  
											  Servo myservo;
											  int pos = 0;
											  
											  void setup() {
												myservo.attach(D2);
											  }
											  
											  void loop() {
												for (pos = 0; pos <= 180; pos += 1) {
												  myservo.write(pos);
												  delay(15);
												}
												for (pos = 180; pos >= 0; pos -= 1) {
												  myservo.write(pos);
												  delay(15);
												}
											  }
											  

Results

  • The servo motor successfully rotated from 0° to 180° and back.
  • The signal was stable, and the servo responded smoothly to the PWM output.
  • Using an external power source prevented voltage drops and jittering.

Conclusion

This week helped me understand how PWM works and how to control mechanical movement using output devices. The XIAO RP2040 performed well in generating consistent PWM signals for servo control. This knowledge can be applied in interactive prototypes, robotics, and simple actuated systems.