Hello everyone,
This is the first time I've used the arduino forum, so I'm sorry in advance if I'm listing my topic incorrectly.
I've been trying to get an SSi distance sensor to work with a MEGA arduino for a while now. The sensor is as follows:
To retrieve its data I use the CLK- and DATA- port with this program:
#define DATA_PIN 3
void setup() {
pinMode(CLOCK_PIN, OUTPUT);
pinMode(DATA_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
uint32_t data = 0;
for (int i = 0; i < 24; i++) {
digitalWrite(CLOCK_PIN, HIGH);
delayMicroseconds(1);
digitalWrite(CLOCK_PIN, LOW);
delayMicroseconds(1);
data = (data << 1) | digitalRead(DATA_PIN);
}
Serial.println(data);
delay(100);
}
When I retrieve my SSI frames everything is fine of course the short distances but when I exceed 2 meters which is half the distance of my sensor which is 4, I get erroneous values in fact it's as if I came back to my first values, moreover my value becomes very unstable once I exceed 2 meters. I'm stuck and feel like I'm missing a bit of information.
If anyone knows what the problem is, I'd be very grateful for any help. Thanks in advance.