Proximity Sensor
Measures distance to nearby objects using infrared or ultrasonic sensing.
Overview
Proximity sensors detect how far an object is from the sensor. ArduinoStudio supports two main types: infrared (Sharp GP2Y0A21YK) and ultrasonic (HC-SR04, MB1000). They emit sensor-data events with distance readings and can trigger actions when an object crosses a configurable threshold distance.
Supported Sensors
| Sensor | Type | Range | Interface |
|---|---|---|---|
| GP2Y0A21YK | Infrared | 10 – 80cm | Analog |
| HC-SR04 | Ultrasonic | 2 – 400cm | Digital (Trig/Echo) |
| MB1000 | Ultrasonic | 20 – 765cm | Analog / PWM |
Wiring Guide
GP2Y0A21YK (Infrared)
| Sensor Pin | Arduino Pin |
|---|---|
| VCC (red) | 5V |
| GND (black) | GND |
| Vo (yellow) | Analog pin (A0–A5) |
HC-SR04 (Ultrasonic)
| Sensor Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| Trig | Any digital pin |
| Echo | Any digital pin |
Usage in ArduinoStudio
Drag the Proximity component onto the canvas. Select the sensor model and assign the appropriate pins. The component continuously reads distance and emits sensor-data events. You can set a threshold distance to trigger actions — for example, stop a robot when it gets within 15cm of a wall.