From the course: Learning Arduino: Pulse Width Modulation
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Controlling a servo with an analog input - Arduino Tutorial
From the course: Learning Arduino: Pulse Width Modulation
Controlling a servo with an analog input
- With just a few additions, I can control the angle of the servo with the potentiometer. In the Arduino IDE, I will select File, Examples, Servo, Knob. With the potentiometer attached to pin A zero, I will upload the code. This example should be familiar in form. This program uses the map function to scale the value red from the potentiometer, to a corresponding angle of rotation on the servo. As I adjust the position of the potentiometer, the servo moves in time. (servo makes buzzing sound) Notice the small buzzing sound I hear when I turn the servo all the way up. You may have also heard this buzzing noise when the servo reached the top and low end of the sweep program. This has to do with manufacturing standards. Some servos simply won't turn the full 180 degrees. This is why it's important to test your servo ahead of time and find the correct operational range for your particular device. If I were to simply add an arm to the end of the Arduino, you could see how I could control a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Comparing DC motors, servos, and stepper motors2m 44s
-
(Locked)
Implementing basic servo control1m 30s
-
(Locked)
Controlling a servo with an analog input1m 18s
-
(Locked)
Controlling a continuous rotation servo with an analog input2m 6s
-
(Locked)
Controlling DC motor speed with an analog input and transistor2m 49s
-
(Locked)
Diving deeper into H bridge control3m 5s
-
(Locked)
Controlling a DC motor with an H bridge2m 30s
-
(Locked)
Challenge: Controlling a DC motor with an H bridge and potentiometer48s
-
(Locked)
Solution: Controlling a DC motor with an H bridge and potentiometer2m 27s
-
(Locked)
-