Aurdino & Servo with Potentiometer

Servo Potentio meter Sketch_bb1

#include <Servo.h>
Servo myservo;
void setup() {
Serial.begin(9600);
myservo.attach(5);
pinMode(A0,INPUT);
}

void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
myservo.write(map(sensorValue, 0, 1023, 0, 180)); // tell servo to go to position in variable ‘pos’
Serial.println(sensorValue);
delay(1);
}

 

 

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s