NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <QTRSensors.h> //SERİ MONİTORLE İŞİN YOKSA SAKIN ACMA ROBOT KAFASINI SALLIYOR
//BEYAZ ZEMİN SİYAH ÇİZGİ VE ÇİZGİ ÜZERİNDE ENGEL VAR ENGELDEN KAÇIP TEKRAR ÇİZGİYE GİRİYOR
#define Kp .1
#define Kd 4
int maksimumhiz = 250;
int hiz = 190;
#define SensorSayisi 6
#define sagmi 11
#define sagmg 6
#define solmi 9
#define solmg 10
int sonhata = 0;
int zemin = 1; //siyah 1 beyaz 0

#define trig1 12
#define echo1 3
#define trig2 5
#define echo2 4
#define trig3 8
#define echo3 7

int sayac = 0;
int a=0;
int b=0;



QTRSensorsAnalog qtra((unsigned char[]) {A0,A1,A2,A3,A4,A5} ,SensorSayisi);
unsigned int sensorler[SensorSayisi];



void setup(){
pinMode(trig1,OUTPUT);
pinMode(trig2,OUTPUT);
pinMode(trig3,OUTPUT);
pinMode(echo1,INPUT);
pinMode(echo2,INPUT);
pinMode(echo3,INPUT);


pinMode(sagmi,OUTPUT);
pinMode(sagmg,OUTPUT);
pinMode(solmi,OUTPUT);
pinMode(solmg,OUTPUT);
pinMode(13,OUTPUT);

pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);


for (int i = 0; i < 70; i++){
digitalWrite(13,HIGH);
delay(20);
qtra.calibrate();
digitalWrite(13,LOW);
delay(20);
}

}

void loop(){
int sens2 = analogRead(A0);
int sens3 = analogRead(A1);
int sens4 = analogRead(A2);
int sens5 = analogRead(A3);
int sens6 = analogRead(A4);
int sens7 = analogRead(A5);



digitalWrite(trig2,LOW);
delayMicroseconds(2);
digitalWrite(trig2,HIGH);
delayMicroseconds(10); //ORTADAKİ MESAFE SENSORUNU OKUTTUK
digitalWrite(trig2,LOW);
int sure2 = pulseIn(echo2,HIGH);
int mesafe2 = (sure2/2) / 29.1;




while(sens2<300||sens3<300||sens4<300||sens5<300||sens6<300||sens7<300){ /*Ortadaki çizgi sensörlerini okuttuk eğer çizgiyi görürse çizgi izleyen döngüsüne girecek.
Şuan SİYAH çizgiyi algılayacak şekilde yazdım eğer BEYAZ çizgi olacaksa (sens4<300&&sens5<300) şeklinde yazacağım*/

a=0; //Aşağıdaki komutlarda adım sayılarını yazdık burada çizgiye girince tekrar sıfırlanıyor ki çizgi üzerinde birden fazla engel varsa robot düzgün çalışsın

int position = qtra.readLine(sensorler,true,zemin); //1 siyah zemin 0 beyaz zemin


int hata = position - 2500;
int pid = Kp * hata + Kd * (hata - sonhata);
sonhata = hata;

int sagmotorhizi = hiz - pid;
int solmotorhizi = hiz + pid;



if (sagmotorhizi > maksimumhiz){
sagmotorhizi = maksimumhiz;
}
if (solmotorhizi > maksimumhiz ){
solmotorhizi = maksimumhiz;
}
if (sagmotorhizi < 0){
sagmotorhizi = 0;
}

if (solmotorhizi < 0){
solmotorhizi = 0;
}

digitalWrite(solmg,LOW);
digitalWrite(sagmg,LOW);
analogWrite(sagmi,sagmotorhizi);
analogWrite(solmi,solmotorhizi);


digitalWrite(trig2,LOW);
delayMicroseconds(2);
digitalWrite(trig2,HIGH); //ORTA SENSORU OKUTTUK
delayMicroseconds(10);
digitalWrite(trig2,LOW);
int sure2 = pulseIn(echo2,HIGH);
int mesafe2 = (sure2/2) / 29.1;

if(mesafe2<20){
break; //ORTA SENSOR 25 TEN KÜÇÜKSE ÇİZGİ İZLEYEN DÖNGÜSÜNDEN ÇIK
}

}


while(mesafe2<20){ //Ortadaki sensorum eğer engel algıladıysa doğal olarak çizgi izleyen döngüsünden çıkıp bu donguye girecektir
digitalWrite(sagmg,LOW); //ve engel algıladığı anda saga tam şekilde donmeye başlayacak.
digitalWrite(solmg,LOW);
analogWrite(sagmi,0);
analogWrite(solmi,255);
delay(420);
a=1; //Bu otonom dönmenin ilk aşamasını bitirdiği anlamına geliyor
break;
}

while(a==1){ //Eğer ortadaki mesafe sensoru 25 ten büyükse ve ilk aşama bittiyse bu döngüye gir ve diğer komutlara bakma
digitalWrite(sagmg,LOW);
digitalWrite(solmg,LOW);
analogWrite(sagmi,hiz);
analogWrite(solmi,hiz); //Düz bir şekilde ilerle
delay(1000);
a=2;
break;
}



while(a==2){ //Eğer adım 2 tamamlanmışsa artık sola, çizgiye dönebilirsin
digitalWrite(sagmg,LOW);
digitalWrite(solmg,LOW);
analogWrite(sagmi,245); //keskin bir şekilde değilde yumuşak bir şekilde geri dönüyor
analogWrite(solmi,150);




int sens2 = analogRead(A0);
int sens3 = analogRead(A1);
int sens4 = analogRead(A2);
int sens5 = analogRead(A3);
int sens6 = analogRead(A4);
int sens7 = analogRead(A5);

if(sens2<300||sens3<300||sens4<300||sens5<300||sens6<300||sens7<300){
break;
}
}







}
     
 
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.