Sensor – Sharp GP2 – Afstand sensor
Hardware
Informatie (ENG)
IR Sensors work by using a specific light sensor to detect a select light wavelength in the Infra-Red (IR) spectrum. By using an LED which produces light at the same wavelength as what the sensor is looking for, you can look at the intensity of the received light. When an object is close to the sensor, the light from the LED bounces off the object and into the light sensor. This results in a large jump in the intensity, which we already know can be detected using a threshold.
Since the sensor works by looking for reflected light, it is possible to have a sensor that can return the value of the reflected light. This type of sensor can then be used to measure how “bright” the object is. This is useful for tasks like line tracking.
Sharp sensor: | Interface: | Meetafstand: |
---|---|---|
GP2Y0A21YK0F | Analoog | 10~80cm |
GP2Y0A41SK0F | Analoog | 4~30cm |
GP2Y0D805Z0F | Analoog | 0.5~5cm |
GP2Y0D810Z0F | Analoog | 2~10cm |
GP2Y0A02YK | Analoog | 20~150cm |
GP2D120 | Analoog | 4~30cm |
Pinout
Arduino
Sluit de module aan volgens onderstaand overzicht:
Script #1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// Sharp IR GP2Y0A41SK0F Distance Test // http://tinkcore.com/sharp-ir-gp2y0a41-skf/ #define sensor A0 // Sharp IR GP2Y0A41SK0F (4-30cm, analog) void setup() { Serial.begin(9600); // start the serial port } void loop() { // 5v float volts = analogRead(sensor)*0.0048828125; // value from sensor * (5/1024) int distance = 13*pow(volts, -1); // worked out from datasheet graph delay(1000); // slow down serial port if (distance <= 30){ Serial.println(distance); // print the distance } } |
Bron: instructables.com
Script #2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/* * created 2013-07-29 * by lisper * function test gp2d120x * */ //connect gp2d120x to A1 #define pin A1 void setup () { Serial.begin (9600); pinMode (pin, INPUT); } void loop () { uint16_t value = analogRead (pin); double distance = get_gp2d120x (value); Serial.println (value); Serial.print (distance); Serial.println (" cm"); Serial.println (); delay (500); } //return distance (cm) double get_gp2d120x (uint16_t value) { if (value < 16) value = 16; return 2076.0 / (value - 11.0); } |
Bron: dfrobot.com
Afmetingen
Schema
Teardown
GEEN GEGEVENS
Datasheet
Fritzing
Downloads
GEEN GEGEVENS