Skip to content

pinMode fails on some boards if inputPin is not set #10

@bergernetch

Description

@bergernetch

The setPins function does not check if the readPin is defined when pinMode is called. On some boards this results in a lockup, when pinMode(-1, INPUT) is called.

See:

pinMode(readPin, INPUT);

Possible solution:

void Shifty::setPins(int dataPin, int clockPin, int latchPin, int readPin) {
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  if(readPin != -1) {
    pinMode(readPin, INPUT);
    this->readPin = readPin;
  }
  this->dataPin = dataPin;
  this->clockPin = clockPin;
  this->latchPin = latchPin;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions