
git
Git is a distributed version control system that tracks changes in any set of computer files.
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.
Servo motors rotate to specific angles based on the width of PWM signals. They have three main connections:
I connected the SG90 servo motor to the XIAO RP2040 as follows:
Note: I used a common GND between the XIAO and the servo power supply to ensure stable signal operation.
I used the Arduino IDE to program the XIAO RP2040. The standard Servo.h
library works with the RP2040 core.
/* Sweep
by BARRAGAN
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/
#include
Servo myservo; // create Servo object to control a servo
// twelve Servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(D2); // attaches the servo on pin 9 to the Servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}
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.