Arduino ile servo motorun hızı nasıl ayarlanır?

682784

Hectopat
Katılım
16 Ocak 2022
Mesajlar
5.732
Makaleler
6
Çözümler
27
Merhaba servo motor hızını nasıl ayarlayabilirim? Kod bu şekilde 5 servo var.
C:
#include <Servo.h>

int x1Pin = A0;
int y1Pin = A1;
int x2Pin = A2;
int y2Pin = A3;
int x3Pin = A4;


Servo motor1; Servo motor2;Servo motor3; Servo motor4;Servo motor5;
 
int SERVOPIN1 = 1;
int SERVOPIN2 = 1;
int SERVOPIN3 = 1;
int SERVOPIN4 = 1;
int SERVOPIN5 = 1;

 
 
void setup() {
pinMode(x1Pin, INPUT);
pinMode(y1Pin, INPUT);
pinMode(x2Pin, INPUT);
pinMode(y2Pin, INPUT);
pinMode(x3Pin, INPUT);
motor1.attach(5);
motor2.attach(6);
motor3.attach(7);
motor4.attach(8);
motor5.attach(9);
}
 
void loop() {
SERVOPIN1 = map(analogRead(x1Pin),0,1023,0,180);
SERVOPIN2 = map(analogRead(y1Pin),0,1023,0,180);
SERVOPIN3 = map(analogRead(x2Pin),0,1023,0,180);
SERVOPIN4 = map(analogRead(y2Pin),0,1023,0,180);
SERVOPIN5 = map(analogRead(x3Pin),0,1023,0,180);
motor1.write(SERVOPIN1);
motor2.write(SERVOPIN2);
motor3.write(SERVOPIN3);
motor4.write(SERVOPIN4);
motor5.write(SERVOPIN5);
}
 

Geri
Yukarı