Pcf8574 library

Hello everyone, I have a question as am worknig on project so i use pcf8574 to control 4 ultrasonic so i work on tinkercad but there is no library for the pcf8574 so can any one help me to find the code....
this is the simulation in tinkercad:

I don't think this will work.

These sensors require very precise timing to measure distance. Precise enough timing will not be possible over the i2c bus.

Connect your sensors directly to Arduino pins. If you need to free-up some pins, perhaps other devices can be connected to the PCF chip?

Any bare chip you use in a circuit must always have a 0.1uF ceramic bypass capacitor across it's Vcc & ground pins, close to the chip. Not having this cap may work in a simulator but probably not in a real circuit.

I have moved your topic to a more suitable part of the form. Please read the sticky post at the top of a section of the forum before you post there, to check your question is relevant for that section.

2 Likes

As PaulRB says, I2C is too slow.

Thinking out loud, what could be possible

you could use

  • 4 pins of the PCF as TRIGGER pins,
  • 4 pins of the PCF as ECHO pins,
  • connect the INTerrupt pin to your MCU.

Set the I2C clock to 800000 or 700000
Send a pulse to the selected HC-SR04 (mark the start time)
Wait for the interrupt of the PCF (mark the end time).

Duration = stop - start
Duration = duration - overhead <<<< to compensate for I2C duration.
distance = duration x speedOfSound.

I am curious if and how well the above works.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.