Loading...
Loading...
// Multi-servo animation
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm;
void setup() {
pwm.begin();
pwm.setPWMFreq(50);
}
void setServoAngle(int servo, int angle) {
int pulse = map(angle, 0, 180, 150, 600);
pwm.setPWM(servo, 0, pulse);
}
void loop() {
// Wave animation
for (int i = 0; i < 5; i++) {
setServoAngle(0, 45);
delay(300);
setServoAngle(0, 135);
delay(300);
}
delay(5000);
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.