雖然可以用紅外線,但是紅外線在機體靜止於地面時,
得到的數據是離地50cm左右的位置,
會發生這樣的原因是紅外線偵測到的位置剛好是機體的陰影,
所以....排除使用紅外線吧...@@
Sharp IR Sensor
http://playground.arduino.cc/Main/SharpIR
以下資料來源為下面連結
http://communityofrobots.com/tutorial/kawal/how-use-sharp-ir-sensor-arduino
Components you'll need:
- Arduino uno
- Sharp GP2D12 or any other analog model like GP2D120
- Half sized breadboard
This is actually explained here but for ease of users i am posting it separately.
Connections:
You can power the arduino through USB or 9V battery.
=========================================int sensorpin = 0; // analog pin used to connect the sharp sensor int val = 0; // variable to store the values from sensor(initially zero) void setup() { Serial.begin(9600); // starts the serial monitor } void loop() { val = analogRead(sensorpin); // reads the value of the sharp sensor Serial.println(val); // prints the value of the sensor to the serial monitor delay(100); // wait for this much time before printing next value
}
沒有留言:
張貼留言