Did anyone know how to program this kind sensor(SensComp 600 series)?
Wire Connect
INIT = 4
OSC = 5
ECHO = 6
I get the result of 191402,191338,191477 keep changing although the distance is same. And how can i convert the value to meter or inches?
#define INIT 4 // Trigger the measurement
#define ECHO1 6 // Receive the ultrasonic signal feedback
#define ECHO2 5 // Receive the ultrasonic signal feedback
void setup()
{
Serial.begin(9600);
pinMode(INIT, OUTPUT);
pinMode(ECHO1, INPUT);
pinMode(ECHO2, INPUT);
delay(1000);
}
void loop()
{
long duration1,duration2;
digitalWrite(INIT, LOW); // trigger the sensor to measure distance
delayMicroseconds(5);
digitalWrite(INIT, HIGH); // finish trigger
delayMicroseconds(80);
duration1 = pulseIn(ECHO1,HIGH); // Read the signal feedback
Serial.print("duration = ");
Serial.print(duration1);
Serial.println();
delay(100);
}