Exit status 1 hatası alıyorum

ceku7878

Üye
Katılım
28 May 2020
Mesajlar
47
Puanları
1
Yaş
26
KODUM AŞAĞIDAKİ GİBİ
Kod:
#include <Servo.h>



Servo servo_z_axis;

Servo servo_x_axis;

Servo servo_y_axis;

Servo servo_clamp;



int x_axis_degree = 90;

int y_axis_degree = 90;

int z_axis_degree = 85;

int clamp_degree = 90;



#define left_joystick_x = A0;

#define left_joystick_y = A1;

#define right_joystick_x = A2;

#define right_joystick_y = A3;



void setup() {

Serial.begin(9600);



servo_z_axis.attach(3);

servo_clamp.attach(5);

servo_x_axis.attach(6);

servo_y_axis.attach(9);

}



void loop() {

int left_joystick_x_value = analogRead(left_joystick_x);

int left_joystick_y_value = analogRead(left_joystick_y);

int right_joystick_x_value = analogRead(right_joystick_x);

int right_joystick_y_value = analogRead(right_joystick_y);



if(left_joystick_x_value < 340) y_axis_degree -=7;

else if(left_joystick_x_value > 680) y_axis_degree +=7;



if(left_joystick_y_value < 340) clamp_degree -=5;

else if(left_joystick_y_value > 680) clamp_degree +=5;



if(right_joystick_x_value < 340) x_axis_degree -=7;

else if(right_joystick_x_value > 680) x_axis_degree +=7;



if(right_joystick_y_value < 340) z_axis_degree -=7;

else if(right_joystick_y_value > 680) z_axis_degree +=7;



z_axis_degree = min(145, max(15, z_axis_degree));

x_axis_degree = min(175, max(40, x_axis_degree));

y_axis_degree = min(150, max(5, y_axis_degree));

clamp_degree = min(90, max(75, clamp_degree));



Serial.print("x_axis_degree : ");

Serial.print(x_axis_degree);

Serial.print(", y_axis_degree : ");

Serial.print(y_axis_degree);

Serial.print(", z_axis_degree 4 : ");

Serial.print(z_axis_degree);

Serial.print(", clamp_degree : ");

Serial.println(clamp_degree);



servo_clamp.write(clamp_degree);

servo_x_axis.write(x_axis_degree);

servo_y_axis.write(y_axis_degree);

servo_z_axis.write(z_axis_degree);

}

VERDİĞİ HATA ŞU ŞEKİLDE

c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino: In function 'void loop()':
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:15:25: error: expected primary-expression before '=' token
#define left_joystick_x = A0;
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:30:42: note: in expansion of macro 'left_joystick_x'
int left_joystick_x_value = analogRead(left_joystick_x);
^~~~~~~~~~~~~~~
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:30:57: error: expected primary-expression before ')' token
int left_joystick_x_value = analogRead(left_joystick_x);
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:16:25: error: expected primary-expression before '=' token
#define left_joystick_y = A1;
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:31:42: note: in expansion of macro 'left_joystick_y'
int left_joystick_y_value = analogRead(left_joystick_y);
^~~~~~~~~~~~~~~
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:31:57: error: expected primary-expression before ')' token
int left_joystick_y_value = analogRead(left_joystick_y);
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:17:26: error: expected primary-expression before '=' token
#define right_joystick_x = A2;
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:32:43: note: in expansion of macro 'right_joystick_x'
int right_joystick_x_value = analogRead(right_joystick_x);
^~~~~~~~~~~~~~~~
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:32:59: error: expected primary-expression before ')' token
int right_joystick_x_value = analogRead(right_joystick_x);
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:18:26: error: expected primary-expression before '=' token
#define right_joystick_y = A3;
^
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:33:43: note: in expansion of macro 'right_joystick_y'
int right_joystick_y_value = analogRead(right_joystick_y);
^~~~~~~~~~~~~~~~
c:\Users\user\AppData\Local\Temp\.arduinoIDE-unsaved2021222-13984-j6x48n.59ma\sketch_mar22a\sketch_mar22a.ino:33:59: error: expected primary-expression before ')' token
int right_joystick_y_value = analogRead(right_joystick_y);
^
Compilation error: Error: 2 UNKNOWN: exit status 1
 
Moderatör tarafında düzenlendi:
sol joystick zaten tanımlı ne demek istediğinizi anlamadım
 
Makro kullanımında hata var.
C++:
right_joystick_x_value = analogRead(right_joystick_x);

Bu kodun içinde iki tane right_joystick_x var derleyici ikisini de A2 ile değiştiriyor sonuç:

C++:
A2_value = analogRead(A2);

Oluyor. Sence çalışır mı? Makro kullanmayı öğrenmelisin.
 
Hataları düzeltip çalıştırabildim ancak kendi etrafında dönmüyor. Her şeyi denedim ama kendi etrafında döndüremiyorum.Diğer hareketlerinde bir sıkıntı yok.Bu konuda ne yapmam gerekir?
 
Dönmez çünkü bu şekilde tasarlanmış. Açıları belirli aealıklarta sınırlandırmışsın aşağıdaki satırlarla.

C++:
z_axis_degree = min(145, max(15, z_axis_degree));

x_axis_degree = min(175, max(40, x_axis_degree));

y_axis_degree = min(150, max(5, y_axis_degree));

clamp_degree = min(90, max(75, clamp_degree));
 
Kusura bakmayın bu ilk projem o yüzden zorlanıyorum.Sınırlamaları genişletsem bile değişiklik olmuyor.Bütün hareketleri çalışıyor ama kendi etrafında dönmüyor
 
Hobi Servolar kendi etrafında dönemez zaten maksimum 359 derece dönebilir.
 

Yeni mesajlar

Forum istatistikleri

Konular
127,965
Mesajlar
913,961
Kullanıcılar
449,611
Son üye
ramazansanli@

Yeni konular

Geri
Üst