728x90

728x90

Wednesday, February 17, 2021

Arduino rotates a servo motor using a potentiometer

In the previous post, I use three tactile switches to rotate a servo motor to three angle positions. However, using a potentiometer, we can continuously rotates the angle of servo motor in accordance to the adjustment of the potentiometer. 

Arduino rotates a servo motor using a potentiometer
A picture of this example

With the  Arduino Servo.h and analogRead function, this task could be done easily. In this example, a potentiometer connects to pin A0 work as an analog input adjusting the angle of rotation. A servo again, connects to pin A3.

Arduino rotates a servo motor using a potentiometer
Connections Diagram

The analogRead() function return a 10-bit (1024) value from any reading from a specific analog input pin. Hence, this analog value must convert from 1024 to 180 in degree. This could be done by a simple equation as will be shown in source code.

Click here to download the sketch archive of this example.

No comments:

Post a Comment

320x50

Search This Blog

tyro-728x90