-
Notifications
You must be signed in to change notification settings - Fork 0
Sensor de distancia SHARP
javierre edited this page May 7, 2019
·
11 revisions

Este sensor óptico tiene un rango de 10-80cm (aunque modelos similares tienen otros rangos).

Es importante saber que SHARP devuelve la distancia en valores analógicos, por tanto es importante que el pin de datos esté conectado a un pin analógico. En el caso de NodeMCU sólo existe un pin analógico: A0.

/*SHARP GP2Y0A21YK0F IR sensor with Arduino and SharpIR library example code. More info: https://www.makerguides.com */
//Include the library
#include <SharpIR.h>
//Define model and input pin
#define IRPin A0
#define model 1080
/*Model :
GP2Y0A02YK0F --> 20150
GP2Y0A21YK0F --> 1080
GP2Y0A710K0F --> 100500
GP2YA41SK0F --> 430
*/
//Setup the sensor object
SharpIR IR_Sensor_1(IRPin, model);
void setup()
{
//Begin serial communication at a baud rate of 9600
Serial.begin(9600);
}
void loop()
{
delay(1000);
int distance_cm = IR_Sensor_1.distance(); // this returns the distance to the object you're measuring
Serial.print("Mean distance: "); // returns it to the serial monitor
Serial.print(distance_cm);
Serial.println(" cm");
}
-
- Acelerómetro-GY-61
- Brújula GY-273
- Buzzer o zumbador
- ESP8266 Deauther
- GPS NEO-6M
- Heltec LoRa
- IMU (Accel, Gyro, Magn)
- Joystick analógico
- Láser lidar 2D
- LDR Keyes K-018
- Leds RGB WS2811
- Led Superlumínico Keyestudio
- Motor DC
- Motor Lego NXT
- NodeMCU
- OLED
- Botón-pulsador
- RFID522
- Sensor barométrico BMP180
- Sensor de distancia HCSR04
- Sensor de distancia SHARP
- Sensor de temperatura DHT11
- Sensor infrarrojo de obstáculos (YL63)
- Servo de rotación continua FS90R
- Servo SG90
- Tacómetro
- TTGO Camera
- Wemos D1 Mini