// Servo kütüphanesi Arduino IDE ile gelir
#include <Servo.h>
// Potansiyometrenin orta bacağı A0'da
const int POT_PIN = A0;
// Servonun turuncu (sinyal) kablosu
const int SERVO_PIN = 9;
Servo servo;
int lastAngle = -1;
void setup() {
servo.attach(SERVO_PIN);
Serial.begin(9600);
}
void loop() {
// 0 (bir uç) ile 1023 (öbür uç) arası
int potValue = analogRead(POT_PIN);
// 0–1023'ü 0–180 dereceye çevir
int angle = map(potValue, 0, 1023, 0, 180);
servo.write(angle);
// Açı değişince Seri Monitöre yaz
if (angle != lastAngle) {
Serial.print("Açı: ");
Serial.println(angle);
lastAngle = angle;
}
// Servo yeni açıya yetişsin
delay(15);
}