Controlling Servo Motor using a Potentiometer and Arduino Nano





Circuit:-



Code:-
#include "Servo.h"

Servo myservo;

int potpin = 0;
int val;

void setup() {
  myservo.attach(9);
}

void loop() {
  val = analogRead(potpin);
  val = map(val, 0, 1023, 0, 180);
  myservo.write(val);
  delay(15);
}



Demo:-


Comments

Popular Posts