Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE
Soo in this project I just got a microservo to turn according to the voltage across a potentiometer.
Demo:
Things Required:
- Arduino UNO
- Jumper Wires
- microservo
- 10k ohm resistor
- Arduino IDE on computer
Code:
View on/ Download from Github: (LINK)
#include<Servo.h>
int servopin=9;
int servopos=0;;
Servo myservo;
int potpin=A0;
int potval;
void setup() {
pinMode(potpin, INPUT);
myservo.attach(servopin);
myservo.write(servopos);
Serial.begin(9600);
}
void loop() {
potval=analogRead(potpin);
servopos=(180.0/1023.0)*potval;
myservo.write(servopos);
Serial.println(servopos);
}
Stay Tuned for upcoming posts on Arduino Projects! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!
Happy Learning!!
