当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 025 - Servo Control

RonWang6个月前 (11-13)电子编程331

You will need to obtain a standard RC servo; any of the small or mid-sized servos will do. Larger servos are not recommended because they require their own power supply as they consume a lot of current. Also, you’ll need a potentiometer; pretty much any value rotary potentiometer will do. I used a 4.7K ohm one for testing. Note that you may also wish to connect your Arduino to an external DC power supply.

Project 25 Basic Servo Control

Arduino Servo Motor Circuit

Arduino Servo Motor Circuit

Arduino Servo Motor Schematic

Arduino Servo Motor Circuit

/* Coding Ron Wang
   Nov.13th 2024
   Autaba support for coding hardware
   Project 25 Basic Servo Control
 */

#include <Servo.h>
Servo servo1; // Create a servo object
void setup()
{
 servo1.attach(5); // Attaches the servo on Pin 5 to the servo object
}
void loop()
{
 int angle = analogRead(0); // Read the pot value
 angle=map(angle, 0, 1023, 0, 180); // Map the values from 0 to 180 degrees
 servo1.write(angle); // Write the angle to the servo
 delay(15); // Delay of 15ms to allow servo to reach position
}

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=279

标签: Arduino

相关文章

Arduino Project 005 - LED Chase Lights

Arduino Project 005 - LED Chase Lights

You’re going to use a string of LEDs (10 in total) to make an LED chase effect, similar to that used...

Arduino Project 029 - Control Stepper Motor ULN2004A

Arduino Project 029 - Control Stepper Motor ULN2004A

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without a...

Arduino Project 012 - Piezo Sounder Melody Player

Arduino Project 012 - Piezo Sounder Melody Player

Rather than using the piezo to make annoying alarm sounds, why not use it to play a melody? You are...

Arduino Programming Basic - If and Loop

Arduino Programming Basic - If and Loop

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

Arduino Programming Basic - Bollean

Arduino Programming Basic - Bollean

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

Arduino Project 020 -  LED Dot Matrix Display - Beat Heart

Arduino Project 020 - LED Dot Matrix Display - Beat Heart

You’re going to use the same circuit, but with a slight variation in the code to create a multi-fram...