-->
Page 1 of 3

Problems with PIN Extender

PostPosted: Mon Oct 08, 2018 1:15 pm
by buzzy
Hey! I am trying to use a 74HC165 to get more INPUT pins on my esp8266.
I have connected everything according to the data sheet, but I still get all zeroes when pulling the values.
I have all 8 "D"-pins on the 74HC165 connected to GND using 10k resistors. Then one of the Pins to a button that pulls it to VCC. Pushing the button has no effect :(

Here is my code:

Code: Select all#include <Arduino.h>
#include <SPI.h>

byte shift_1;

void setup() {
    Serial.begin(9600);
    SPI.setClockDivider(SPI_CLOCK_DIV2);
    SPI.setDataMode(SPI_MODE0);
    SPI.setBitOrder(MSBFIRST);
    SPI.begin();

    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);
}

void loop() {
    digitalWrite(4, LOW);
    shift_1 = SPI.transfer(0);
    digitalWrite(4, HIGH);

    Serial.print(micros());
    Serial.print(" Register 1 = ");
    Serial.println(shift_1, BIN);

    delay(1000);
}


I have also attached a picture of my wiring. What am I doing wrong? :(

Re: Problems with PIN Extender

PostPosted: Mon Oct 08, 2018 2:43 pm
by rudy
I have connected everything according to the data sheet


No you didn't. http://www.ti.com/lit/ds/symlink/sn74hc165.pdf 10 Power Supply Recommendations

How much work do you expect someone to put in in order to help you? Do you not think that providing a schematic of your circuit would be helpful? The picture of your wiring is poor. It is hard to see where in the breadboard the wires end up. A picture is useful in order to see in general how you have done things. What things you have left out. (like bypass capacitors)

At this point I need to trace out your circuit to see if what you have done is actually correct. I need to look up the pin functions for your ESP8266 board, the pin functions for the 74HC165. Then go through your code and make sure you did all that right.

When you ask for help be considerate. Try and make it easier for someone to help you.

Re: Problems with PIN Extender

PostPosted: Mon Oct 08, 2018 4:18 pm
by martinayotte
Why not using a simple I2C GPIO Expander such MCP23017 ?
It is much simplier to use than trying to mux pins using those 74HC165 ...

Re: Problems with PIN Extender

PostPosted: Tue Oct 09, 2018 12:17 am
by buzzy
rudy wrote:
I have connected everything according to the data sheet


No you didn't. http://www.ti.com/lit/ds/symlink/sn74hc165.pdf 10 Power Supply Recommendations

How much work do you expect someone to put in in order to help you? Do you not think that providing a schematic of your circuit would be helpful? The picture of your wiring is poor. It is hard to see where in the breadboard the wires end up. A picture is useful in order to see in general how you have done things. What things you have left out. (like bypass capacitors)

At this point I need to trace out your circuit to see if what you have done is actually correct. I need to look up the pin functions for your ESP8266 board, the pin functions for the 74HC165. Then go through your code and make sure you did all that right.

When you ask for help be considerate. Try and make it easier for someone to help you.


Sorry about that. I have attached the schematics. Adding a 0.1uF capacitor made no difference.