還是利用之前的 BaseCar(好人的 arduino 庫: 智能小車行走部分)和兩個紅外線距離傳感器,再來做一個循跡小車,。
硬件列表:
再來看一個視頻: http://v.youku.com/v_show/id_XMjUyMjk0MTE2.html 最后看源碼: ================================================================== #include
<BaseCar.h>
// log const boolean VERBOSE = true; const int SERIAL_SPEED = 9600; // for Car const int MOTO1_PIN = 10; const int MOTO2_PIN = 11; const int I11_PIN = 6; const int I12_PIN = 7; const int I21_PIN = 8; const int I22_PIN = 9; // for Trace Sensor const int LEFT_PIN = 3; const int RIGHT_PIN = 4; // speed const int SPEED_VAL = 150; // delay const int DELAY_TIME = 300; // car control BaseCar car(MOTO1_PIN, MOTO2_PIN, I11_PIN, I12_PIN, I21_PIN, I22_PIN); const int adj = -19; void setup() { } void loop() { } |
|