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

Arduino Project 027 - Joystick Servo Control

RonWang1个月前 (11-15)电子编程75

In this tutorial, we are going to learn how to use Arduino and a joystick to control two servo motors or a pan-tilt kit with servos.

Project 27  Joystick Servo Control

/* Coding Ron Wang
   Nov.15th 2024
   Autaba support for coding hardware
   Project 27  Joystick Servo Control
 */

#include <Servo.h>
Servo servo1; // Create a servo object
Servo servo2; // Create a second servo object
int pot1, pot2;
void setup()
{
 servo1.attach(5); // Attaches the servo on pin 5 to the servo1 object
 servo2.attach(6); // Attaches the servo on pin 6 to the servo2 object
 servo1.write(90); // Put servo1 at home position
 servo2.write(90); // Put servo2 at home postion
}
void loop()
{
 pot1 = analogRead(3); // Read the X-Axis
 pot2 = analogRead(4); // Read the Y-Axis
 pot1 = map(pot1,0,1023,0,180);
 pot2=map(pot2,0,1023,0,180);
 servo1.write(pot1);
 servo2.write(pot2);
 delay(15);
}

Arduino Joystick Servo Control Circuit

Arduino Joystick Servo Control Schematic

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

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

标签: Arduino

相关文章

Arduino Project 008 - RGB LED Mood Lamp

Arduino Project 008 - RGB LED Mood Lamp

In the last project, you learned how to adjust the brightness of an LED using the PWM capabilities o...

Arduino Project 045 - RFID Servo and LED Control System

Arduino Project 045 - RFID Servo and LED Control System

Arduino Programming Basic -- RFID Servo and LED Control System Project 45 RFID Servo...

Arduino Programming Basic - If and Loop

Arduino Programming Basic - If and Loop

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

Arduino Project 001 - LED Blink

Arduino Project 001 - LED Blink

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目项目1 Project...

Arduino Project 035 - Keypad 4X4 or 4X3

Arduino Project 035 - Keypad 4X4 or 4X3

Most of the time we are used key, button, or switch to get input value in our projects. When we inte...

Arduino Project 028B - Basic Stepper Control (Unipolar)

Arduino Project 028B - Basic Stepper Control (Unipolar)

In this very simple project, you will connect up a stepper motor and then get the Arduino to control...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。