Line Follower (Arduino)

Gauloran

Kıdemli Moderatör
7 Tem 2013
8,096
585
local
GDbnly.jpg


Line Follower (Arduino)

Most of you have heard of the line follower robot. Have you ever thought about how the robot perceives the line? In this topic, I'll tell you about the sensor and I'll talk about the Arduino codes. (Sensor name is QTR-8A)

Working Principle

the QTR-8A doesn't consist of a single sensor. It has 8 sensors on it. This sensor sends infrared (IR) rays across the lower part and hits the lower part, so it comes to the upper part. It generates a value based on the force of the corresponding rays and communicates through the analog inputs of Arduino (or any card). Even in competitions, they can cheat, they can hold a laser on the robot's sensor

b6Q8WY.jpg


connections

The connections are very easy. Since Arduino Uno has 6 analog inputs, we'll consider 6 sensors of the QTR-8A. Numbers 1 to 8 above QTR-8A are the number of sensors.
Sensor numbers = to Arduino analog inputs, Vcc = 5V, Gnd = Gnd, Ledon = to any digital output pins.
For testing purposes, you can use a breadboard and male-to-male jumper wires.
I'll leave a visual here for you:

g6jlQQ.jpg


How Is It Used In Programming?

As I said in the working principle, we'll use the values it provides us. Because IR is reflected in light on a white background, its analog value will be high, and its value on a black background will be low. On the black ground, the value is less than 50. We can accept other situations as else.

for example

Kod:
if(sensor1<=50)
s1 = 1;
else
s1 = 0;

if(sensor2<=50)
s2 = 2;
else
s2 = 0;

if(sensor3<=50)
s3 = 3;
else
s3 = 0;

So if the sensor is on the black ground s1=1, if not s1 = 0

By collecting the number of these "s" variables, we can understand which ones are in the white ground and which ones are in the black ground.

for example

Kod:
int control = s1 + s2 + s3 + s4 + s5 + s6;

If the control variable is 3+4=7, then the black line is under sensors 3 and 4. I mean, straight. If the control variable is 2+3=5, then the black line is under sensors 2 and 3. In this case, the left engine should slow down and the right engine should accelerate. Because the line must be centered. If the control variable is below the sensor 1 and sharp rotation is required. In this case, the left engine should stop and go back if necessary. In addition, the right engine also needs to accelerate. Thanks to small calculations, it follows the line straight, and its deviation decreases.

Source: https://www.turkhackteam.org/elektrik-elektronik/1719823-cizgi-sensoru-qtr-8a-lost.html
Çevirmen/Translator Gauloran
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.