if (sensorState == LOW) Serial.println("OBSTACLE DETECTED!"); digitalWrite(LED_BUILTIN, HIGH); else Serial.println("Clear path"); digitalWrite(LED_BUILTIN, LOW);
(model FC-51) is a staple for hobbyist robotics and smart car projects. Known for its simplicity and low cost, this module uses infrared reflection to detect nearby objects without physical contact. Technical Datasheet Overview Mh Sensor Series Flying Fish Ir Sensor Datasheet Fixed
| Pin Number (from left) | Label on Fixed Datasheet | Wire Color Recommendation | Function | |------------------------|--------------------------|---------------------------|-----------| | 1 | VCC (5V) | Red | Power supply input (3.3V to 5V DC) | | 2 | GND | Black | Common ground | | 3 | OUT | Yellow/White | Digital output (TTL: LOW when obstacle detected, HIGH when clear) | if (sensorState == LOW) Serial