#include <Servo.h>
Servo myservo;
int angle = 0;
bool direction = true;
void setup() {
Serial.begin(9600);
myservo.attach(9); // PWM pin
Serial.println("Servo power measurement simulation started...");
}
void loop() {
myservo.write(angle);
Serial.print("Angle: ");
Serial.print(angle);
Serial.print(" degrees\tVoltage: 5V (fixed)\tEstimated Current: ~100-250mA depending on load\n");
delay(1000);
if (direction) {
angle += 45;
if (angle >= 180) direction = false;
} else {
angle -= 45;
if (angle <= 0) direction = true;
}
}