IR Proximity Sensor (adjustable)

This water-proof sensor can detect if there's an object within its range using infrared light. The range is configurable up to 2 meters and the sensor is waterproof.

Ideal use cases: checking if your car is in the garage, cheaking if there are letters in your mailbox, ...

Buy this sensor from DFRobot (They kindly provided me with this sensor).

Full code

#include <Arduino.h>

#define SENSOR_PIN 5

void setup() {
Serial.begin(9600);
pinMode(SENSOR_PIN, INPUT);
}

void loop() {
Serial.print("Sensor value: ");
Serial.println(digitalRead(SENSOR_PIN));

delay(500);
}

💌 Subscribe to my newsletter

Monthly newsletter with cool stuff I found on the internet
(related to science, technology, biology, and other nerdy things)!
Check out past editions.