Araba projesinde yarıya geldim aşağıdaki kodlarımda herhangi bi sıkıntı görünmüyor. ancak "pulseIn" hatası alıyorum. kodları ve hata mesajı aşağıdaki gibidir. yardımcı olur musun?
C:\Users\Musa M\Documents\Arduino\sketch_aug22a/sketch_aug22a.ino:78: undefined reference to `pulseIn'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
KODLAR
Kod:
#include <IRremote.h>
const int ir_kumanda_pini = 2;
const int OUT1 = 5;
const int OUT2 = 6;
const int OUT3 = 7;
const int OUT4 = 8;
const int motor_konrol_1 = 9;
const int motor_konrol_2 = 10;
const int echoPin = 11;
const int trigPin = 12;
int hiz = 150;
IRrecv ir_alicim(ir_kumanda_pini);
decode_results results;
void setup() {
pinMode(OUT1, OUTPUT);
pinMode(OUT2, OUTPUT);
pinMode(OUT3, OUTPUT);
pinMode(OUT4, OUTPUT);
pinMode(motor_konrol_1, OUTPUT);
pinMode(motor_konrol_2, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(trigPin, OUTPUT);
digitalWrite(motor_konrol_1, LOW);
digitalWrite(motor_konrol_2, LOW);
digitalWrite(OUT1, LOW);
digitalWrite(OUT2, LOW);
digitalWrite(OUT3, LOW);
digitalWrite(OUT4, LOW);
ir_alicim.enableIRIn();
Serial.begin(9600);
}
void loop() {
int mesafe = mesafe_olcumu();
Serial.println("Mesafe: " + String(mesafe) + " cm");
if (ir_alicim.decode(&results)) {
switch (results.value) {
case 16718055: // İleri
ileri();
break;
case 16730805: // Geri
geri();
break;
case 16716015: // Sol
sola_don();
break;
case 16734885: // Sağ
saga_don();
break;
case 16738455: // Hız Arttır
hiz_arttir();
break;
case 16756815: // Hız Azalt
hiz_azalt();
break;
case 16750695: // Dur
dur();
break;
}
ir_alicim.resume();
}
}
int mesafe_olcumu() {
long sure, mesafe;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
sure = pulseIn(echoPin, HIGH);
mesafe = sure / 29.1 / 2;
delay(50);
return mesafe;
}
void ileri() {
digitalWrite(OUT1, HIGH);
digitalWrite(OUT2, LOW);
digitalWrite(OUT3, HIGH);
digitalWrite(OUT4, LOW);
analogWrite(motor_konrol_1, hiz);
analogWrite(motor_konrol_2, hiz);
}
void geri() {
digitalWrite(OUT1, LOW);
digitalWrite(OUT2, HIGH);
digitalWrite(OUT3, LOW);
digitalWrite(OUT4, HIGH);
analogWrite(motor_konrol_1, hiz);
analogWrite(motor_konrol_2, hiz);
}
void sola_don() {
digitalWrite(OUT1, HIGH);
digitalWrite(OUT2, LOW);
digitalWrite(OUT3, LOW);
digitalWrite(OUT4, HIGH);
analogWrite(motor_konrol_1, hiz);
analogWrite(motor_konrol_2, hiz);
}
void saga_don() {
digitalWrite(OUT1, LOW);
digitalWrite(OUT2, HIGH);
digitalWrite(OUT3, HIGH);
digitalWrite(OUT4, LOW);
analogWrite(motor_konrol_1, hiz);
analogWrite(motor_konrol_2, hiz);
}
void hiz_arttir() {
hiz = min(hiz + 10, 255);
}
void hiz_azalt() {
hiz = max(hiz - 10, 0);
}
void dur() {
digitalWrite(OUT1, LOW);
digitalWrite(OUT2, LOW);
digitalWrite(OUT3, LOW);
digitalWrite(OUT4, LOW);
analogWrite(motor_konrol_1, 0);
analogWrite(motor_konrol_2, 0);
}
HATA MESAJI
C:\Users\MUSAM~1\AppData\Local\Temp\ccA87HU1.ltrans0.ltrans.o: In function `mesafe_olcumu':C:\Users\Musa M\Documents\Arduino\sketch_aug22a/sketch_aug22a.ino:78: undefined reference to `pulseIn'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
Last edited by a moderator: