Kodla Büyü
Z

Arduino Joystick Modül Kullanarak Kartondan V22 Osprey Yapımı

#include <AFMotor.h>
#include <Servo.h>
const int SW_pin = 1; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output
AF_DCMotor motor1(4);
AF_DCMotor motor2(3);
Servo servo1;
Servo servo2;
int x_durum;
int x_durum1;
int x_durum2;
int y_durum;
void setup()
{
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
servo1.attach(9);
servo2.attach(10);
motor1.setSpeed(255);
motor1.run(RELEASE);
motor2.setSpeed(255);
motor2.run(RELEASE);
}
void loop() {
x_durum = analogRead(X_pin);
y_durum = analogRead(Y_pin);
x_durum1 = map(x_durum , 0 , 1023, 0, 180);
x_durum2 = map(x_durum , 0 , 1023, 180, 0);
y_durum = map(y_durum , 0 , 1023, 0, 250);
servo1.write(x_durum1);
servo2.write(x_durum2);
delay(50);
if(y_durum>100){
motor1.run(RELEASE);
motor2.run(RELEASE);
}else{
motor1.run(FORWARD);
motor2.run(FORWARD);
}
}
  • Beğen
Tepkiler: kgunduz
Kodla Büyü

Medya bilgileri

Category
Teknoloji ve Tasarım
Added by
zafererisen
Date added
View count
1,387
Comment count
0
Değerlendirme
0.00 yıldız 0 değerlendirme

Share this media

Geri
Üst