Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
const int echo= 7;
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 sol_durum1, sol_durum2, orta_durum, sag_durum1, sag_durum2; // 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);
}
void loop()
{
for(int i=0; i<1; i++)
{
arama();
}
{
digitalWrite(trig , HIGH); // hc-sr04 kullanılarak mesafe hesaplandı
delayMicroseconds(1000); // mesafe hesabının ayrıntıları için videoya bakınız
digitalWrite(trig , LOW); // http://lezzetlirobottarifleri.com/video/hc-sr04-mesafe-sensoru-ve-29-1-degeri
sure = pulseIn(echo , HIGH);
mesafe = (sure / 2) / 28.5;
if (mesafe > 30)
{
sol_durum1 = digitalRead(sol_sensor1); // sol ve sağ sensör okunup değişkenlere kaydedildi.||
sol_durum2 = digitalRead(sol_sensor2);
orta_durum = digitalRead(orta_sensor);
sag_durum1 = digitalRead(sag_sensor1);
sag_durum2 = digitalRead(sag_sensor2);
if (sol_durum1 == 1 && sol_durum2 == 1 && sag_durum1 == 1 && sag_durum2 == 1 && orta_durum == 1) // iki sensör de siyah görmüyor ise motorlar ileri gidecek şekilde çalışıtırıldı.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}
else if (sol_durum1 == 1 && sol_durum2 == 1 && sag_durum1 == 0 && sag_durum2 == 0 && orta_durum == 0) // sağ sensör siyah görüyor ise motorlar sağa dönecek şekilde çalıştırıldı.
{
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, HIGH);
digitalWrite(sol_g, LOW);
}
else if (sol_durum1 == 0 && sol_durum2 == 0 && sag_durum1 == 1 && sag_durum2 == 1 && orta_durum == 0) // sol sensör siyah görüyor ise motorlar sola dönecek şekilde çalıştırıldı.
{
digitalWrite(sag_i, HIGH);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}
else //eğer yukarıda şartların 3 üde değilse dur.
{
digitalWrite(sag_i, LOW);
digitalWrite(sag_g, LOW);
digitalWrite(sol_i, LOW);
digitalWrite(sol_g, LOW);
}
delay(25); // ivme kırıcı kodlar, bunların mantığı videolarda anlatıldı arkadaşlar.
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(sol_durum1 == 1 && sol_durum2 == 1 && sag_durum1 == 1 && sag_durum2 == 1 && orta_durum==1)
{
digitalWrite(trig , HIGH); // hc-sr04 kullanılarak mesafe hesaplandı
delayMicroseconds(1000); // mesafe hesabının ayrıntıları için videoya bakınız
digitalWrite(trig , LOW); // http://lezzetlirobottarifleri.com/video/hc-sr04-mesafe-sensoru-ve-29-1-degeri
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
{
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
{
digitalWrite(sol_i , HIGH);
digitalWrite(sol_g , LOW);
digitalWrite(sag_i , HIGH);
digitalWrite(sag_g , LOW);
}
}
}
![]() |
Notes is a web-based application for online 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 14 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