#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Servo.h>
Servo servoMotor1;
Servo servoMotor2;
int xPin = A0; // Joystick x ekseni pin
int yPin = A1; // Joystick y ekseni pin
int xValue, yValue;
int xMapped, yMapped;
int servo1Position = 90; // Servo motor 1 başlangıç pozisyonu
int servo2Position = 90; // Servo motor 2 başlangıç pozisyonu
int sensitivity = 5; // Hassasiyet ayarı, isteğe bağlı olarak değiştirilebilir
void setup() {
servoMotor1.attach(9); // Servo motor 1 pin
servoMotor2.attach(10); // Servo motor 2 pin
}
void loop() {
xValue = analogRead(xPin);
yValue = analogRead(yPin);
xMapped = map(xValue, 0, 1023, -sensitivity, sensitivity);
yMapped = map(yValue, 0, 1023, -sensitivity, sensitivity);
servo1Position += xMapped;
servo2Position += yMapped;
servo1Position = constrain(servo1Position, 0, 180); // Sınırlama aralığı
servo2Position = constrain(servo2Position, 0, 180); // Sınırlama aralığı
servoMotor1.write(servo1Position);
servoMotor2.write(servo2Position);
delay(15); // Gecikme süresi isteğe bağlı olarak ayarlanabilir
}
// Servo servoMotor1;
// Servo servoMotor2;
// int xPin = A0; // Joystick x ekseni pin
// int yPin = A1; // Joystick y ekseni pin
// int xValue, yValue;
// int xMapped, yMapped;
// int servo1Min = 0; // Servo motor 1 minimum derece
// int servo1Max = 180; // Servo motor 1 maksimum derece
// int servo2Min = 30; // Servo motor 2 minimum derece
// int servo2Max = 150; // Servo motor 2 maksimum derece
// void setup() {
// servoMotor1.attach(9); // Servo motor 1 pin
// servoMotor2.attach(10); // Servo motor 2 pin
// }
// void loop() {
// xValue = analogRead(xPin);
// yValue = analogRead(yPin);
// xMapped = map(xValue, 0, 1023, servo1Min, servo1Max);
// yMapped = map(yValue, 0, 1023, servo2Min, servo2Max);
// servoMotor1.write(xMapped);
// servoMotor2.write(yMapped);
// delay(150); // Gecikme süresi isteğe bağlı olarak ayarlanabilir
// }
// int trigPin=7;
// int echoPin=4;
// void setup() {
// // put your setup code here, to run once:
// pinMode(trigPin, OUTPUT);
// pinMode(echoPin, INPUT);
// Serial.begin(9600);
// Serial.print("OLED READINGS\n");
// }
// void loop() {
// // put your main code here, to run repeatedly:
// int distance;
// int duration;
// digitalWrite(trigPin, LOW);
// delayMicroseconds(2);
// digitalWrite(trigPin, HIGH);
// delayMicroseconds(10);
// digitalWrite(trigPin, LOW);
// duration = pulseIn(echoPin,HIGH);
// distance = duration * 0.344/2;
// Serial.print("Distance: ");
// Serial.println(distance);
// }