티스토리 뷰

#include <servo.h>

int potVal;
int angle;

Servo myServo;

void setup() {
  myServo.attach(8, 640, 2400);
  Serial.begin(9600);
}

void loop() {
  potVal = analogRead(A0);
  angle = (potVal / 1023.0) * 180.0;
  myServo.write(angle);
  Serial.print("angle : ");
  Serial.println(angle);
  delay(15);
}
댓글