No. 1 and No. 2 is almost same programming source. But if you have a close look at motor icon, you can simply check the direction. No. 1 is just to change speed to re-detect line correctly. No. 2 is turing direction to re-detect line. Two programs don't have the case, which both of IR sensors detect black line.
Why don't you assemble simple Line tracer using KRC and program these by KAILab S/W? Change the speed and make turn right and left. You can recognize what's difference.
You can have various experience depending on MAP design and position of IR sensors.
If you change the speed slower, KRC Line Tracer can trace along the sharp curve line.
Using this above program, it may happen this problem as below.
* KRC Line Tracer is programmed to trace black line by changing the speed according to detection of IR sensors. Actually it is not turing right or left when it detects corner like this. Then KRC line tracer may get out of line as below. It just simply pass the black line by acceleration. *
Or it may happen like this as below,
* When 2ea IR sensor detect black line, it won't move at all. Because I didn't program in this case which both of 2ea IR sensors of KRC Line Tracer detects black line. *
Here's the example for another programming source
This program is like this. If 2ea IR sensor detect white paper (IR > 150), it goes forward 2ea LED lighting up. If right side of IR sensor detect black line and left side of IR sensor detect white paper, it turns right. If left side of IR sensor detect black line and right side of IR sensor detect white line, it turns left. If both of IR sensors detect black line, it also goes forward. * You can check this logic in above programming source. *
Let's see the Line Tracer using 2ea IR sensors and 2ea LEDs If you click the image, then it will be enlarged for your reference.
Let's see the struction of KAI Line Tracer
Let's see the programming source
The map has a black line on white paper. I programmed 2ea IR sensor detect white paper : (IR > 150) means IR sensor detects more reflected light via white color. If sensor value is over 150 (IR > 150), the IR sensor is on the white paper. So 2ea IR sensors detect white paper, it will forward while 2ea LEDs are lighting up. If IR sensor detects black line, LED will be off and make a turn to redetect white paper.
Due to the inertia, I didn't make left or right turn. I use difference of 2ea DC motors' speed to make a little turn via speed difference. If KRC Line tracer gets out of black line far away, then it will just go forward because it will detect only white paper. According to the position of IR sensors and speed of DC motors, you should program differently. I will show you another sample with different design and programming source.
Let's have a look at KAI programming. A short Video Cip
Kaimax wishes all our Chinese friends Happy Lunar New Year 恭喜发财,万事如意。
Explorer KAIrobot model use 2ea IR sensors, 1ea Light sensor, 2ea LED, 1ea touch sensor, 1ea Sound sensor. When you switch on the power, you can hear the buzzer twice and see 2ea LEDs emit. Then if you press a touch sensor at the behind of robot, 2ea LED lights off and go forward to avoid obstruction using 2ea IR sensors. When it's dark (no light) in the room, 2ea LED light up. When it detects noisy or sound ("Danger" in the video), it stops and buzzer 4 times while 2ea LED light up.
* Let's have a look at the program by KAILab. Using GUI icon, every one even primary school students can program for their own robot by KAILab Software!!!!!