IR LED emits infrared radiation. This radiation
illuminates the surface in front of LED. Surface reflects the infrared
light. Depending on reflectivity of the surface, amount of light
reflected varies. This reflected light is made incident on reverse
biased IR sensor. When photons are incident on reverse biased junction
of this diode, electron-hole pairs are generated, which results in
reverse leakage current. Amount of electron-hole pairs generated depends
on intensity of incident IR radiation. More intense radiation results
in more reverse leakage current. This current can be passed through a
resistor so as to get proportional voltage. Thus as intensity of
incident rays varies, voltage across resistor will vary accordingly.
This voltage can then be given to OPAMP based
comparator.Output of the comparator can be read by uC. Alternatively,
you can use on-chip ADC in AVR microcontroller to measure this voltage
and perform comparison in software.
( sumber: IR sensor)
Line follower robot that I made consisting of two pairs of infrared sensors. the way it works is if the right sensor over the line then the robot will move left, if left out of the line sensor, the robot will move to right.
Here's video line follower robot that I made
and this program
void setup() { pinMode(2,OUTPUT); // kendali motor 1 pinMode(3,OUTPUT); // motor 1 + pinMode(4,OUTPUT); // motor 1 - pinMode(5,OUTPUT); // kendali motor 2 pinMode(6,OUTPUT); // motor 2 + pinMode(7,OUTPUT); // motor 2 - //pinMode(13,OUTPUT); // Buzzer Serial.begin(9600); } void kanan(void){ digitalWrite(2,LOW); digitalWrite(5,LOW); delayMicroseconds(100); digitalWrite(3,HIGH); digitalWrite(4,LOW); delayMicroseconds(100); digitalWrite(6,LOW); digitalWrite(7,HIGH); delayMicroseconds(100); digitalWrite(2,HIGH); digitalWrite(5,HIGH); delayMicroseconds(200); } void kiri(void){ digitalWrite(2,LOW); digitalWrite(5,LOW); delayMicroseconds(100); digitalWrite(3,LOW); digitalWrite(4,HIGH); delayMicroseconds(100); digitalWrite(6,HIGH); digitalWrite(7,LOW); delayMicroseconds(100); digitalWrite(2,HIGH); digitalWrite(5,HIGH); delayMicroseconds(200); } void maju(void){ digitalWrite(2,LOW); digitalWrite(5,LOW); delayMicroseconds(100); digitalWrite(3,LOW); digitalWrite(4,HIGH); delayMicroseconds(100); digitalWrite(6,LOW); digitalWrite(7,HIGH); delayMicroseconds(100); digitalWrite(2,HIGH); digitalWrite(5,HIGH); delayMicroseconds(200); } void henti(void){ digitalWrite(2,LOW); digitalWrite(5,LOW); delayMicroseconds(100); digitalWrite(3,LOW); digitalWrite(4,LOW); delayMicroseconds(100); digitalWrite(6,LOW); digitalWrite(7,LOW); delayMicroseconds(100); digitalWrite(2,LOW); digitalWrite(5,LOW); delayMicroseconds(200); } void loop() { int sensor,sensor2; // baca nilai sensor di PIN A0 (Analog) dan kirim ke serial sensor=analogRead(A0);//kanan sensor2=analogRead(A1); //kiri Serial.println(sensor); if(sensor>=900&&sensor2>=900) { maju(); //digitalWrite(13,LOW); } if (sensor<900){ kiri(); } if(sensor2<900){ kanan(); } if(sensor<900 && sensor2<900){ henti(); delay(200); kanan(); if(sensor >= 900 || sensor2 >= 900) { maju(); } delay(500); } }
Tidak ada komentar:
Posting Komentar