2016年11月18日 星期五

[Arduino]Sharp 2Y0A21


雖然可以用紅外線,但是紅外線在機體靜止於地面時,
得到的數據是離地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
}

沒有留言:

張貼留言

[Sensor]MPU92/65

MPU92/65是很久以前買的感測器 基本上有加速度計、陀螺儀、電子羅盤、溫度計 以下是該電子商城的介紹 https://www.factoryforward.com/product/gy-87-mpu-9265-3-axis-9-dof-attitude-gyro-magnet...