What it is: An IR obstacle-avoidance sensor has an infrared LED and a receiver side by side. When something reflects the IR back, it flags an obstacle. It's the cheap "bumper" sensor on line-follower and obstacle-avoiding robots.
How it works: It's a digital sensor — its OUT pin goes LOW when an obstacle is detected within range (a few cm to ~30 cm, set by the onboard trimmer). No analog reading needed.
Wiring:
IR OUT -> GPIO10 (digital)
IR VCC -> 3V3
IR GND -> GND
OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5
Libraries: only "Adafruit SSD1306" and "Adafruit GFX Library".
On screen / Serial: "CLEAR" or "OBSTACLE". Wave your hand in front of it and adjust the trimmer to set the trigger distance.
Gotchas: OUT is active-LOW on almost all of these modules (LOW = obstacle), which is why the code inverts it. Range and reliability drop on dark or matte surfaces that absorb IR. Bright sunlight can cause false triggers.