84Views1Replies

Author Options:

How do I change this code to account for only 1 shift register? Answered

Hi,
I am trying to make a midi keyboard as shown

https://www.youtube.com/watch?v=lXX8v-ZW6Tk

But I am not sure how to change this section of code to account for only one shift register (as seen at 5:35 of the video above):

void scanColumn(int colNum)
{
  digitalWrite(latchPin, LOW);

  if(0 <= colNum && colNum <= 7)
  {
    shiftOut(dataPin, clockPin, MSBFIRST, B11111111); //right sr
    shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum]); //left sr
  }
  else
  {
    shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum-8]); //right sr
    shiftOut(dataPin, clockPin, MSBFIRST, B11111111); //left sr
  }
  digitalWrite(latchPin, HIGH);
}


Can someone help please?!

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
steveastrouk
steveastrouk

5 years ago

void scanColumn(int colNum)
{
digitalWrite(latchPin, LOW);

if(0 <= colNum && colNum <= 7)
{
shiftOut(dataPin, clockPin, MSBFIRST, B11111111); //right sr
shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum]); //left sr
}
digitalWrite(latchPin, HIGH);
}