I used a Pcf8574 to connect mechanical switches and it worked fine but the switches are old and unrelieble. So I replaced them with an opto switch. The Pcf8574 has a pull up resistor and I also placed a resistor between +5 and the opto switch. I tested the opto switch alone and it drops from 5 to 0.when I connect it to the pcf8574 I have a solid +5. I then removed the Pcf8574 pull up resistor and I have a solid 2v value. I'm doing something wrong but what? Any help is welcomed
Can you post a data sheet for the opto switch? And a schematic of your wiring? Many optical switch type devices are open collector so need a pullup in order to work.
groundFungus: Can you post a data sheet for the opto switch? And a schematic of your wiring? Many optical switch type devices are open collector so need a pullup in order to work.
I have pull up resistor and the circuit stand alone works fine. The problem comes when I connect it to pcf8574. The circuit is very simple : 5 v - resistor- opto switch-pcf8574. The infrared emitter has its own power
Written descriptions of circuits are often ambiguous. A schematic drawing is less so. Drawn by hand, photographed and posted as an image is fine. How to post an image.
Is this how it is wired?
How it should be:
It is like the second drawing.
Please post your code. Still would like to see a data sheet for the opto switch.
No code involved yet just have test. I don't have that dare sheet, bought on ebay code 362191010732
bought on ebay code 362191010732
That is no help. Can you link to the page from which you got the opto switch?
I don't suppose that you can post a schematic of the test setup or a photo of the setup. i am working from the dark here. You can see what you are doing and I can't.
Many thanks for your help! You confirmed that the theory was correct so if it doesn’t work something is wrong in implementation.
I’ve found a wrong connection with the power. I tested everything using one power line and it was ok then I separated the led power from the receiver power and I missed up. Now it works! :-[