NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include<SoftwareSerial.h>

const int trig =6;
const int echo= 7;
SoftwareSerial BT1(0, 1);
char data;

const int sol_i = 4; // motor sürücü pinleri tanımlandı
const int sol_g = 5;
const int sag_i = 2;
const int sag_g = 3;

const int sol_sensor1 = 13;
const int sol_sensor2 = 12;
const int orta_sensor = 11;
const int sag_sensor1 = 10;
const int sag_sensor2 = 9;

int S1, S2, S3, S4, S5; // sol ve sağ sensörün durum değişkenleri tanımlandı


int sure = 0; // mesafe hesabından kullanılacak olan değişkenler tanımladı
int mesafe = 0;
int count = 1;


void setup()

{
pinMode(trig , OUTPUT); // sensörün trigger pini çıkış olarak ayarlandı
pinMode(echo , INPUT ); // sensörün echo pini giriş olarak ayarlandı

pinMode(sol_i, OUTPUT); // motor sürücü pinleri çıkış olarak ayarlandı
pinMode(sol_g, OUTPUT);
pinMode(sag_i, OUTPUT);
pinMode(sag_g, OUTPUT);

pinMode(sol_sensor1, INPUT); // sensör pinleri giriş pini olarak atandı
pinMode(sol_sensor2, INPUT);
pinMode(orta_sensor, INPUT);
pinMode(sag_sensor1, INPUT);
pinMode(sag_sensor2, INPUT);

Serial.begin(9600);
BT1.begin(9600);

}



void loop()
{
if (BT1.available())
{
data=BT1.read();
BT1.println(data);
}

if(data=='1'){


arama();
{
digitalWrite(trig , HIGH);
delayMicroseconds(1000);
digitalWrite(trig , LOW);

sure = pulseIn(echo , HIGH);
mesafe = (sure / 2) / 28.5;

if (mesafe > 30)
{

S1 = digitalRead(sol_sensor1); // sol ve sağ sensör okunup değişkenlere kaydedildi.||
S2 = digitalRead(sol_sensor2);
S3 = digitalRead(orta_sensor);
S4 = digitalRead(sag_sensor1);
S5 = digitalRead(sag_sensor2);

if (S1 == 1 && S2 == 1 && S4 == 1 && S5 == 1 && S3 == 0) // sensörler siyah görmüyor ise 2 motor çalışıyor.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}
else if ((S1 == 1 && S2 == 1) || ((S1 == 1) && (S2 == 1)) && S4 == 0 && S5 == 0 && S3 == 0) // sağ sensör siyah görüyor ise sol motor çalışıyor.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}

else if ((S4 == 1 && S5 == 1) || ((S4 == 1) && (S5 == 1)) && S1 == 0 && S2 == 0 && S3 == 0) // sol sensör siyah görüyor ise sağ motor çalışıyor.
{
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}
else if(S1 == 0 && S2 == 0 && S4 == 0 && S5 == 0 && S3 == 0) // hiçbir sensör siyah görmüyorsa ise sol motor çalışıyor.
{
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}

else if(S1 == 1 && S2 == 0 && S4 == 0 && S5 == 1 && S3 == 0) // ortada ki 3 sensör siyah görüyor ise 2 motor çalışıyor.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}


else if(S1 == 0 && S2 == 0 && S4 == 0 && S5 == 1 && S3 == 0) // ortada ki 3 sensör siyah görüyor ise 2 motor çalışıyor.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}

else if(S1 == 1 && S2 == 0 && S4 == 0 && S5 == 0 && S3 == 0) // ortada ki 3 sensör siyah görüyor ise 2 motor çalışıyor.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}

else if(data=='0'){
delay(25); // ivme kırıcı kodlar
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
delay(50);
}
}
}
}
else
{
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}


}

void arama()
{


while(S1 == 1 && S2 == 1 && S4 == 1 && S5 == 1 && S3==1)
{

if (BT1.available())
{
data=BT1.read();
}

if(data='1'){
S1 = digitalRead(sol_sensor1); // sol ve sağ sensör okunup değişkenlere kaydedildi.||
S2 = digitalRead(sol_sensor2);
S3 = digitalRead(orta_sensor);
S4 = digitalRead(sag_sensor1);
S5 = digitalRead(sag_sensor2);

digitalWrite(trig , HIGH);
delayMicroseconds(1000);
digitalWrite(trig , LOW);

sure = pulseIn(echo , HIGH);
mesafe = (sure / 2) / 28.5;

if (mesafe < 10 ) // mesafe 30cm den küçük ise robotu geri al ve döndür
{
delay(150);
digitalWrite(sol_i , LOW);
digitalWrite(sol_g , HIGH);
digitalWrite(sag_i , LOW);
digitalWrite(sag_g , LOW);
delay(150);

}
else // mesafe 30cm den büyük ise düz git
{
delay(150);
digitalWrite(sol_i , HIGH);
digitalWrite(sol_g , LOW);
digitalWrite(sag_i , HIGH);
digitalWrite(sag_g , LOW);
delay(150);
}
delay(25); // ivme kırıcı kodlar
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
delay(50);
}

else if(data=='0'){
delay(25); // ivme kırıcı kodlar
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
delay(50);
}

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.