Joystick ve Servo Motor Uygulaması

By gokhan, 29 Mayıs 2017

Bu uygulamada 2 eksende hareketi sağlayan iki tane servo motorun kontrolü Joystick ile hareket ettirilerek webcam ile görüntülenme yapabileceğimiz ya da hedefleme sistemi olarak kullanabileceğimiz bir devre elde edilebilir.
Servo motorları bağlarken dikkat etmenz gereken en önemli kısım ~işaretli çıkışlara bağlamak!!!!

[csharp]
#include <Servo.h>
Servo CAMservo1;
Servo CAMservo2;

const int servo1 = 5;
const int servo2 = 6;
const int Jstick1 = 0; // Sol-Sağ
const int Jstick2 = 1; // Yukarı-Aşağı

int ServValue;

void setup() {
Serial.begin(9600);
CAMservo1.attach(servo1);
CAMservo2.attach(servo2);
}

void loop(){
PrintValue();
ServValue = analogRead(Jstick1);
ServValue = map(ServValue, 0, 1023, 0, 180);
CAMservo2.write(ServValue);
ServValue = analogRead(Jstick2);
ServValue = map(ServValue, 0, 1023, 70, 180);
CAMservo1.write(ServValue);
delay(15);

}

void PrintValue(){

Serial.print(analogRead(Jstick1));
Serial.print (" – ");
Serial.print(analogRead(Jstick2));
Serial.println (" Joystick Deger:");
}
[/csharp]