mBlock 單元十九:紅外線循跡自走車 ( mBlock Unit 19: A Line Following Car )

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

本文的原理部分可參考碁峰出版的 <Arduino自走車最佳入門與應用:打造輪型機器人輕鬆學>一書。本文車子的控制方法如下表:

The rules for the action of the car are:
Left IR Sensor
Middle IR Sensor
Right IR Sensor
Car Action
0
0
0
Forward
0
0
1
Turn Right Quickly
0
1
0
Forward
0
1
1
Turn Right Slowly
1
0
0
Turn Left Quickly
1
0
1
Stop
1
1
0
Turn Left Slowly
1
1
1
Stop


要挑戰的路徑如下圖所示 (The Path for this tutorial is):

硬體材料:
1. Arduino UNO R3 板子 x 1
2. Arduino 感測器擴展板 Sensor Shield V5.0 x 1
3. 5V 直流馬達 x 2
4. 紅外線循跡模組 x 3
5. L298N 馬達驅動板 x 1
6. 小車底盤 x 1
7. 小車輪子 x 2
8. 萬向輪 x 1
9. 緊固件 x 4
10. M2銅柱 x 4
11. M2螺帽 x 7
12. M2*3cm 螺絲 x 4
13. M2*1cm 螺絲 x 11
14. 兩節18650電池盒 x 1
15. 18650電池 x 2
16. 免焊接DC公頭 5.5-2.1mm x 1
17. 公對公杜邦線 x 6
18. 母對母杜邦線 x 13
19. 橡皮筋兩條

Materials:
1. Arduino UNO R3  x 1
2. Arduino sensor shield V5.0 x 1
3. IR Line tracking sensor x 3
4. L298N motor driver module x 1
5. Car chassis kit (Like this one)6. 2-pack battery holder for 18650  x 1
7 18650 battery x 2
8. 5.5mm x 2.1mm 12V DC power male jack connector plug adapter x 19. Male to male wire jumper x 6
10. Female to female wire jumper x 13
11. Rubber bands

硬體電路(The Circuit):


接線對應腳位
L298N馬達驅動板 The connections for L298N
  • IN1 接 Arduino D5 (L298N IN1 --> Arduino D5)
  • IN2 接 Arduino D6 (L298N IN2 --> Arduino D6)
  • IN3 接 Arduino D9 (L298N IN3 --> Arduino D9)
  • IN4 接 Arduino D10 (L298N IN4 --> Arduino D10)
  • 12V 接 Arduino 5V (L298N 12V --> Arduino 5V)
  • GND 接 Arduino GND (L298N GND --> Arduino GND)
須注意紅外線循跡模組放在自走車的位置,程式是以接上Arduino腳位來判斷左(數位腳 2)中(數位腳 3)右(數位腳 4)的位置。
The left IR sensor is on the left side of the car. And it's signal pin is connected to UNO D2.
The middle IR sensor is on the middle of the car. And it's signal pin is connected to UNO D3.
The right IR sensor is on the right side of the car. And it's signal pin is connected to UNO D4.

完成圖(The finished car):


程式積木(The mBlock code):


示範影片(Demo videos):




給讀者的思考點:
1. 用長方形的路徑,結果會如何?
2. 若左右輪的轉速不一樣時如何調整?
3. 地面摩擦力的影響?
4. 一定要用3個紅外線循跡模組?
5. 在競速比賽中,如何取勝?

Questions:
1. If the path is rectangle, what will happen?
2. How to adjust a single wheel's rotational speed?
3. The effect of friction between the ground and the car?
4. Could we use more IR line tracking sensors?
5. How to win in a car racing competition?

沒有留言: