Hi!
I wonder how to connect ultrasonic sensor to arduino using an expander. The main problem is that the library "PCF8574.h" does not support the function pulseIn, which is necessary to get the value of time. Is it posible to do this? Maybe by using pulseIn function with address of the exact pin, but I don't now how. Please help me
Here is my code:
#define trig 2
#define echo 1
#include <Wire.h>Â Â // Required for I2C communication
#include "PCF8574.h" // Required for PCF8574
/* PCF8574 instance */
PCF8574 expander;
void setup() {
 /* Setup serial for debug */
 Serial.begin(9600);
 delay(3000);
 /* Start I2C bus and PCF8574 instance */
 expander.begin(0x20);
  /* Setup some PCF8574 pins for demo */
 expander.pinMode(trig, OUTPUT);
 expander.pinMode(echo, INPUT);
}
void loop() {
int time, dist;
expander.digitalWrite(trig, HIGH);
delayMicroseconds(1000);
expander.digitalWrite(trig, LOW);
// ?? THIS LINE ??
time = expander.pulseIn(echo, HIGH);
// OR MAYBE LIKE THIS
// time = pulseIn(0x20,HIGH);
dist = (time/2)/29.1;
Serial.println(dist);
}