Arama butonu
Bu konudaki kullanıcılar: 1 misafir
2
Cevap
267
Tıklama
0
Öne Çıkarma
Arduino L298p ile motor sürme sorunu acil
C
11 yıl
Yüzbaşı
Konu Sahibi

Arkadaslar arduino ve l289p ile motor sürmeye çalışıyorum bunun yanında ayrıca mesafe sensörüyle de kontrolü sağlamaya çalısıyorum.
mesefeyi algılayınca geri gidiyor sonra tekrar ileri gidiyor.ama ne yaptıysam motorlar çalısmıyor.simdi kodları paylasacagım sizinle.umarım bi sorun yoktur kartta
  




const int trigPin = 7;
const int echoPin=4;
void setup() {
Serial.begin(9600);
//establish motor direction toggle pins
pinMode(12, OUTPUT); //drive motor -- HIGH = forwards and LOW = backwards
pinMode(13, OUTPUT); //turn motor -- HIGH = left and LOW = right

//establish motor brake pins
pinMode(9, OUTPUT); //brake (disable) the drive motor
pinMode(8, OUTPUT); //brake (disable) the turn motor

//Turns brake off for drive motor
digitalWrite(9, LOW);

//Turns brake on for turn motor
digitalWrite(8, HIGH);

//Sets initial speed of drive motor
analogWrite(3, 200);

//Sets initial direction of drive motor
digitalWrite(12, HIGH);
}

void loop()
{
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;

// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(5);
digitalWrite(trigPin, LOW);

// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);

// convert the time into a distance
inches = microsecondsToInches(duration);

//
//if objects are less than 12 inches away
//the robot reverses and turns to the right
//for 2 seconds
//

if (inches < 12){

//brake drive motor and pause 1/10 second
digitalWrite(9, HIGH);
delay(100);

//
//setting turn motor
//

//turn off brake for turn motor
digitalWrite(8, LOW);

//set turn motor direction
digitalWrite(13, HIGH);

//activate turn motor
analogWrite(11, 255);

//
//setting drive motor
//

//turn off brake of drive motor
digitalWrite(9, LOW);

//set drive motor backwards direction
digitalWrite(12, LOW);

//activate the drive motor
analogWrite(3, 200);
//backup for 2 seconds
delay(2000);

//
//stopping
//

//brake both motors
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);

}

//
//when nothing is within 12"
//the robot simply drives forwards
//

else{

//
//Setting drive motor
//

//set drive motor forward direction
digitalWrite(12, HIGH);

//turn off brake of drive motor
digitalWrite(9, LOW);

//activate drive motor
analogWrite(3, 200);

}

delay(100);
}

long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}


motorları da l298p nin a ve b çıkışlarına bağlıyorum ama nafile.

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



C
11 yıl
Yüzbaşı
Konu Sahibi

Arkadaslar up up .ne olur ne olmaz hangi pinlere ne gelecek onu da söyler misiniz .mantıksal olarak en doğrusunu yaptığımı biliyorum hepsi doğru ama çıldırmak üzereyim



< Bu ileti mobil sürüm kullanılarak atıldı >

C
11 yıl
Yüzbaşı
Konu Sahibi

Arkadaslar a ve b motorunu bağlıyorum ışıklar yanıyor elimi yaklaştırınca sönüyor falan ama motorlar hareket etmiyor sinir bozucu .up



< Bu ileti mobil sürüm kullanılarak atıldı >

DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.