10. Output Devices¶
Hero Shot !
Group Assignment¶
For more details, visit our lab site: Tech Works - Output devices
Fixing the Board¶
I re-cut the board due to issues with the traces. I adjusted the trace thickness to 0.4 mm instead of 2.5 mm, and I also used sandpaper to clean them after the cutting process.
I encountered an issue while cutting the board’s outline. By mistake, I changed the CNC tool’s X and Y zero positions, which caused a trace at the upper-right edge to get separated. I later fixed this by using a very tiny wire to reconnect the two cut traces.
XIAO RP2040 with Servo Motor¶
Wiring
To control a servo motor using the XIAO RP2040, connect the signal pin of the servo motor to one of the PWM-capable pins on the XIAO RP2040. In my setup, the signal pin is connected to pin P0.
Programming
Below you can find the code I used to program the XIAO RP2040 to control the servo.
#include "Servo.h"
Servo myservo;
#define servoPin 0
void setup() {
myservo.attach(servoPin);
}
void loop() {
// Sweep from 0 to 180 degrees:
for (int angle = 0; angle <= 180; angle += 1) {
myservo.write(angle);
delay(15);
}
// And back from 180 to 0 degrees:
for (int angle = 180; angle >= 0; angle -= 1) {
myservo.write(angle);
delay(15);
}
delay(1000);
}
Files