شحن مجاني للأوردرات فوق
1000 ج
رمضان كريم
3-80cm Proximity Detection with Digital Output for Arduino and Robotics Projects
The E18-D80NK is an adjustable infrared proximity sensor with reliable detection range from 3cm to 80cm. This photoelectric switch features a potentiometer for sensitivity adjustment and provides both analog and digital output signals.
3cm to 80cm detection distance
Onboard sensitivity adjustment
Digital (TTL) and analog signals
IP67 waterproof rating
| Detection Range | 3cm – 80cm (adjustable) |
|---|---|
| Operating Voltage | 5V DC ±10% |
| Current Consumption | 25mA max |
| Output Type | Digital (TTL) + Analog |
| Response Time | 2ms |
| Protection Rating | IP67 (Dustproof/Waterproof) |
| Ambient Temperature | -25°C to +55°C |
| Cable Length | 45cm (standard) |

| Wire Color | Function | Arduino Connection |
|---|---|---|
| Brown | VCC (+5V) | 5V |
| Blue | GND | GND |
| Black | Digital Output | Digital Pin |
| White | Analog Output | Analog Pin (optional) |

// Basic Digital Connection: // Brown → 5V // Blue → GND // Black → D2 (or any digital pin) // Optional Analog Connection: // White → A0 (for distance estimation)

const int sensorPin = 2; // Digital input pin
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
int detection = digitalRead(sensorPin);
if (detection == LOW) {
Serial.println("Object detected!");
} else {
Serial.println("No object detected");
}
delay(100);
}
const int analogPin = A0; // Only if white wire present
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(analogPin);
float voltage = sensorValue * (5.0 / 1023.0);
// Approximate distance calculation (requires calibration)
float distance = 80.0 * (1.0 - (voltage / 5.0));
Serial.print("Analog Value: ");
Serial.print(sensorValue);
Serial.print("\tEstimated Distance: ");
Serial.print(distance);
Serial.println("cm");
delay(200);
}
int objectCount = 0;
bool lastState = HIGH;
void loop() {
bool currentState = digitalRead(sensorPin);
if (lastState == HIGH && currentState == LOW) {
objectCount++;
Serial.print("Objects passed: ");
Serial.println(objectCount);
}
lastState = currentState;
}
long lastDetection = 0;
float objectSpeed = 0;
void loop() {
if (digitalRead(sensorPin) == LOW) {
long now = millis();
if (lastDetection > 0) {
objectSpeed = 1000.0 / (now - lastDetection); // Hz
Serial.print("Frequency: ");
Serial.print(objectSpeed);
Serial.println("Hz");
}
lastDetection = now;
}
}
const int sensorPins[] = {2, 3, 4};
const int numSensors = 3;
void checkSensors() {
for (int i=0; i<numSensors; i++) {
if (digitalRead(sensorPins[i]) == LOW) {
Serial.print("Sensor ");
Serial.print(i);
Serial.println(" triggered");
}
}
}
No account yet?
Create an Account
Recent Comments