makerbase-mks / MKS-TinyBee

MKS TinyBee is a mainboard for 3d printing, based on ESP32 module
GNU General Public License v3.0
116 stars 115 forks source link

How to Control the Pins with the 74HC595 Shift Register? #113

Closed SphaeroX closed 7 months ago

SphaeroX commented 7 months ago

Helllo i buyed the MKS TinyBee for an Project and now im not able to Set the Output of some pins.

Here is what im try to do:

// IOExpander.h
#ifndef IO_EXPANDER_H
#define IO_EXPANDER_H

#define DATA_PIN 25
#define LATCH_PIN 26
#define CLOCK_PIN 27

void setupIOExpander()
{
    pinMode(DATA_PIN, OUTPUT);
    pinMode(LATCH_PIN, OUTPUT);
    pinMode(CLOCK_PIN, OUTPUT);
}

void test()
{
    byte patternHigh = 0b11111111;
    byte patternLow = 0b00000000;

    Serial.println("HIGH");
    digitalWrite(LATCH_PIN, LOW);
    for (int i = 0; i < 3; i++)
    {
        shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, patternHigh);
    }
    digitalWrite(LATCH_PIN, HIGH);

    delay(1000);

    Serial.println("LOW");
    digitalWrite(LATCH_PIN, LOW);
    for (int i = 0; i < 3; i++)
    {
        shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, patternLow);
    }
    digitalWrite(LATCH_PIN, HIGH);
}

#endif

but all signals are still low, what im doing wrong?

SphaeroX commented 7 months ago

I don't know why but know it works