Shift Register Issues

Hello, I am currently working on a project using the Arduino Leonardo. I have a 4x4 matrix keypad connected to pins 2,3,4,5,6,7 and 8. The shift Register 74HC595N connected to Pins 11,12, and 13 and is connected to an external 5V supply. The 8 outputs of the shift register are currently connected LCD light bulbs going to GND. The purpose of my project will be to as I push button 1 through 8 on the matrix keypad the LED on the corresponding shift register pin.

The issue I am having is the lights are not always turning on when they should and takes SEVERAL button pushes to actually turn them on. The following code is the code I am using.

#include <Keypad.h>

const byte ROWS = 4; // Four rows

const byte COLS = 3; // Three columns

// Define the Keymap

char keys[ROWS][COLS] =

{

{‘1’,‘2’,‘3’},

{‘4’,‘5’,‘6’},

{‘7’,‘8’,‘9’},

{‘#’,‘0’,‘*’}

};

byte rowPins[ROWS] = { 2, 3, 4, 5 }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins(2,3,4,5).

byte colPins[COLS] = { 6, 7, 8 }; // Connect keypad COL0, COL1 and COL2 to these Arduino pins(6,7,8.

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad

int dataPin = 11; //Define which pins will be used for the Shift Register control

int latchPin = 13;

int clockPin = 12;

int Room1 = 0;

int Room2 = 0;

int Room3 = 0;

int Room4 = 0;

int Room5 = 0;

int Room6 = 0;

int Room7 = 0;

int Room8 = 0;

int Rooms = B00000000;

int DigitalState;

void setup()

{

pinMode(dataPin, OUTPUT); //Configure each IO Pin

pinMode(latchPin, OUTPUT);

pinMode(clockPin, OUTPUT);

Serial.begin(9600);

Serial.println(“reset”);

}

void loop()

{

char key = kpd.getKey();

if(key) // Check for a valid key.

{

switch (key)

{

case ‘1’:

DigitalState = digitalRead(Room1); // read value currently for Room 1

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room1, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 0, 0);// Writes 0 to the 0bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room1, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 0, 1);// Writes 0 to the 0bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘2’:

DigitalState = digitalRead(Room2); // read value currently for Room 2

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room2, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 1, 0);// Writes 0 to the 1bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room2, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 1, 1);// Writes 0 to the 1bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘3’:

DigitalState = digitalRead(Room3); // read value currently for Room 3

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room3, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 2, 0);// Writes 0 to the 2bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room3, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 2, 1);// Writes 0 to the 2bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘4’:

DigitalState = digitalRead(Room4); // read value currently for Room 4

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room4, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 3, 0);// Writes 0 to the 3bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room4, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 3, 1);// Writes 0 to the 3bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘5’:

DigitalState = digitalRead(Room5); // read value currently for Room 5

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room5, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 4, 0);// Writes 0 to the 4bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room5, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 4, 1);// Writes 0 to the 4bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘6’:

DigitalState = digitalRead(Room6); // read value currently for Room 6

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room6, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 5, 0);// Writes 0 to the 5bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room6, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 5, 1);// Writes 0 to the 5bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘7’:

DigitalState = digitalRead(Room7); // read value currently for Room 7

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room7, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 6, 0);// Writes 0 to the 6bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room7, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 6, 1);// Writes 0 to the 6bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

case ‘8’:

DigitalState = digitalRead(Room8); // read value currently for Room 8

if (DigitalState == HIGH)// check if value is high

{

digitalWrite(Room8, LOW);// If HIGH write room light to LOW

bitWrite(Rooms, 7, 0);// Writes 0 to the 7bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

else

{

digitalWrite(Room8, HIGH);// If LOW write room light to HIGH

bitWrite(Rooms, 7, 1);// Writes 0 to the 7bit of the Rooms word

digitalWrite(latchPin, LOW);// So the LED’s dont change as bits get shifted

shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register

digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED’s will light up

}

break;

}

}

}

I can’t determine why it takes so long to recognize another button push.

Does anybody know what my problem is or knows another way to solve it?

Thanks!

The first thing to do is figure out where the problem lies. Put some more print statements in to show which key was pressed. Figure out whether the problem lies in the detection or in getting the data out to the SR’s.

BTW your code will be much easier to read (and so likely to get read) if you do this:

(click on the open and enlarge)

Then your code will look like this:

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] =
{
  {
    '1','2','3'  }
  ,
  {
    '4','5','6'  }
  ,
  {
    '7','8','9'  }
  ,
  {
    '#','0','*'  }
};

byte rowPins[ROWS] = { 
  2, 3, 4, 5 }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins(2,3,4,5).
byte colPins[COLS] = { 
  6, 7, 8 }; // Connect keypad COL0, COL1 and COL2 to these Arduino pins(6,7,8.

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad

int dataPin = 11; //Define which pins will be used for the Shift Register control
int latchPin = 13;
int clockPin = 12;
int Room1 = 0;
int Room2 = 0;
int Room3 = 0;
int Room4 = 0;
int Room5 = 0;
int Room6 = 0;
int Room7 = 0;
int Room8 = 0;
int Rooms = B00000000;
int DigitalState;

void setup()
{
  pinMode(dataPin, OUTPUT); //Configure each IO Pin
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("reset");
}


void loop()
{
  char key = kpd.getKey();
  if(key) // Check for a valid key.
  {
    switch (key)
    {
    case '1':
      DigitalState = digitalRead(Room1); // read value currently for Room 1
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room1, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 0, 0);// Writes 0 to the 0bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room1, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 0, 1);// Writes 0 to the 0bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '2':

      DigitalState = digitalRead(Room2); // read value currently for Room 2
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room2, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 1, 0);// Writes 0 to the 1bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room2, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 1, 1);// Writes 0 to the 1bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '3':

      DigitalState = digitalRead(Room3); // read value currently for Room 3
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room3, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 2, 0);// Writes 0 to the 2bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room3, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 2, 1);// Writes 0 to the 2bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '4':

      DigitalState = digitalRead(Room4); // read value currently for Room 4
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room4, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 3, 0);// Writes 0 to the 3bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room4, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 3, 1);// Writes 0 to the 3bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '5':

      DigitalState = digitalRead(Room5); // read value currently for Room 5
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room5, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 4, 0);// Writes 0 to the 4bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room5, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 4, 1);// Writes 0 to the 4bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '6':

      DigitalState = digitalRead(Room6); // read value currently for Room 6
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room6, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 5, 0);// Writes 0 to the 5bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room6, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 5, 1);// Writes 0 to the 5bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '7':

      DigitalState = digitalRead(Room7); // read value currently for Room 7
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room7, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 6, 0);// Writes 0 to the 6bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room7, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 6, 1);// Writes 0 to the 6bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    case '8':

      DigitalState = digitalRead(Room8); // read value currently for Room 8
      if (DigitalState == HIGH)// check if value is high
      {
        digitalWrite(Room8, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 7, 0);// Writes 0 to the 7bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        digitalWrite(Room8, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 7, 1);// Writes 0 to the 7bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

    }

  }
}

I would add something like the following to all the “cases” :

void loop()
{
  char key = kpd.getKey();
  if(key) // Check for a valid key.
  {
    switch (key)
    {
    case '1':
      Serial.print("Case 1 : ");
      DigitalState = digitalRead(Room1); // read value currently for Room 1
      if (DigitalState == HIGH)// check if value is high
      {
        Serial.println(" High");
        digitalWrite(Room1, LOW);// If HIGH write room light to LOW
        bitWrite(Rooms, 0, 0);// Writes 0 to the 0bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      else
      {
        Serial.println(" Low");
        digitalWrite(Room1, HIGH);// If LOW write room light to HIGH
        bitWrite(Rooms, 0, 1);// Writes 0 to the 0bit of the Rooms word
        digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
        shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
        digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
      }
      break;

… just to see that each key press was being picked up, decoded and the correct code path invoked.

Hey Mee_n_mac!

thanks a lot for your reply. I have updated my code with what you suggested and am able to determine that the button presses are all going through however only sometimes will they change the state of the pin. The after pressing button one 3 times, button two 3 times, and button five 4 times, the serial monitor appears as:

Case 1 : HIGH

Case 1 : LOW

Case 1 : LOW

Case 2 : LOW

Case 2 : LOW

Case 2 : LOW

Case 5 : HIGH

Case 5 : LOW

Case 5 : LOW

Case 5 : LOW

when what should be happening is:

Case 1 : HIGH

Case 1 : LOW

Case 1 : HIGH

Case 2 : HIGH

Case 2 : LOW

Case 2 : HIGH

Case 5 : HIGH

Case 5 : LOW

Case 5 : HIGH

Case 5 : LOW

I cant figure out why it isn’t following the code as typed.

Here is the code I updated

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = 
{
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'#','0','*'}
};

byte rowPins[ROWS] = { 2, 3, 4, 5 }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins(2,3,4,5).
byte colPins[COLS] = { 6, 7, 8 }; // Connect keypad COL0, COL1 and COL2 to these Arduino pins(6,7,8.

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad

int dataPin = 11; //Define which pins will be used for the Shift Register control
int latchPin = 13;
int clockPin = 12;
int Room1 = 0;
int Room2 = 0;
int Room3 = 0;
int Room4 = 0;
int Room5 = 0;
int Room6 = 0;
int Room7 = 0;
int Room8 = 0;
int Rooms = B00000000;
int DigitalState;

void setup()
{
 pinMode(dataPin, OUTPUT); //Configure each IO Pin
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 Serial.begin(9600);
 Serial.println("reset");
}


void loop()
{
 char key = kpd.getKey();
 if(key) // Check for a valid key.
 { 
   switch (key)
     { 
       case '1':
       Serial.print("Case 1 : "); //print case in serial Monitor
       DigitalState = digitalRead(Room1); // read value currently for Room 1
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room1, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 0, 0);// Writes 0 to the 0bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room1, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 0, 1);// Writes 0 to the 0bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
          }
       break;

       case '2':
       Serial.print("Case 2 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room2); // read value currently for Room 2
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room2, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 1, 0);// Writes 0 to the 1bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room2, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 1, 1);// Writes 0 to the 1bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '3':
       Serial.print("Case 3 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room3); // read value currently for Room 3
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room3, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 2, 0);// Writes 0 to the 2bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room3, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 2, 1);// Writes 0 to the 2bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '4':
       Serial.print("Case 4 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room4); // read value currently for Room 4
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room4, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 3, 0);// Writes 0 to the 3bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room4, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 3, 1);// Writes 0 to the 3bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '5':
       Serial.print("Case 5 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room5); // read value currently for Room 5
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room5, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 4, 0);// Writes 0 to the 4bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room5, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 4, 1);// Writes 0 to the 4bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
          }
       break;

       case '6':
       Serial.print("Case 6 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room6); // read value currently for Room 6
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room6, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 5, 0);// Writes 0 to the 5bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room6, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 5, 1);// Writes 0 to the 5bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '7':
       Serial.print("Case 7 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room7); // read value currently for Room 7
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room7, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 6, 0);// Writes 0 to the 6bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room7, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 6, 1);// Writes 0 to the 6bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '8':
       Serial.print("Case 8 : ");//print case in serial Monitor
       DigitalState = digitalRead(Room8); // read value currently for Room 8
       if (DigitalState == HIGH)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           digitalWrite(Room8, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 7, 0);// Writes 0 to the 7bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           digitalWrite(Room8, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 7, 1);// Writes 0 to the 7bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;
      }
    }
  }

k_rawn:
I cant figure out why it isn’t following the code as typed.

Oh but it is ! :twisted: It wasn't obvious to me until I looked closely at what the code did, not what I thought you intended it to do. Look at this line :
       DigitalState = digitalRead(Room1); // read value currently for Room 1
       if (DigitalState == HIGH)// check if value is high

What is it really doing ? You declared the variable Room1 to be an int as initialized it to a zero. When you do the digitalRead(Room1) you’re reading the value that happens to be on pin0 at that moment. Or perhaps pin1, depending on how Room1 gets set. I think what you intended was to store the state of room1 in the variable Room1, that is Room1 is either a 0 or a 1. You could have declared all the RoomX variables (Room1, Room2, etc) as booleans and set them TRUE or FALSE. Your test (above) could have been :

if(Room1)// check if value is high

But you’d still be storing the state of the room in 2 places, the RoomX variable and as a bit in the Rooms variable. Perhaps it would be best to use just 1 variable to store the state. You need Rooms to clock out to the SRs, why not test the bit for each room by doing the appropriate bitRead(Rooms, n), where n is the bit corresponding to room/case ? The above test then becomes (I think).

if (bitRead(Rooms, 0)) // check if value is high

(I think the bit for room1 is the LSB and not the MSB but you check the above and make it correct)

BTW I didn’t think the problem was going to be in the code. This is a good lesson as to why you check even those things you’re “sure” of and leave no stone unturned when T/S’ing.

Thanks a lot for your help, its my first arduino project so still trying to learn.

I changed the code so I only need the Rooms variable like you had suggested, this makes more sense then moving one variable into another like I was doing:

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = 
{
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'#','0','*'}
};

byte rowPins[ROWS] = { 2, 3, 4, 5 }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins(2,3,4,5).
byte colPins[COLS] = { 6, 7, 8 }; // Connect keypad COL0, COL1 and COL2 to these Arduino pins(6,7,8.

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad

int dataPin = 11; //Define which pins will be used for the Shift Register control
int latchPin = 13;
int clockPin = 12;
boolean Rooms = B00000000;


void setup()
{
 pinMode(dataPin, OUTPUT); //Configure each IO Pin
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 Serial.begin(9600);
 Serial.println("reset");
}


void loop()
{
 char key = kpd.getKey();
 if(key) // Check for a valid key.
 { 
   switch (key)
     { 
       case '1':
       Serial.print("Case 1 : "); //print case in serial Monitor
       //DigitalState = digitalRead(Room1); // read value currently for Room 1
       //if (DigitalState == HIGH)// check if value is high
       if(Rooms, 0) //check if value is high
         {
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           //digitalWrite(Room1, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 0, 0);// Writes 0 to the 0bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           //digitalWrite(Room1, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 0, 1);// Writes 0 to the 0bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
          }
       break;

       case '2':
       Serial.print("Case 2 : ");//print case in serial Monitor
       //DigitalState = digitalRead(Room2); // read value currently for Room 2
       //if (DigitalState == HIGH)// check if value is high
       if(Rooms, 1) //check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           //digitalWrite(Room2, LOW);// If HIGH write room light to LOW
           bitWrite(Rooms, 1, 0);// Writes 0 to the 1bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           //digitalWrite(Room2, HIGH);// If LOW write room light to HIGH
           bitWrite(Rooms, 1, 1);// Writes 0 to the 1bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '3':
       Serial.print("Case 3 : ");//print case in serial Monitor
       //DigitalState = digitalRead(Room3); // read value currently for Room 3
       if (Rooms, 2)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 2, 0);// Writes 0 to the 2bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           bitWrite(Rooms, 2, 1);// Writes 0 to the 2bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '4':
       Serial.print("Case 4 : ");//print case in serial Monitor
       if (Rooms, 3)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 3, 0);// Writes 0 to the 3bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           bitWrite(Rooms, 3, 1);// Writes 0 to the 3bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '5':
       Serial.print("Case 5 : ");//print case in serial Monitor
       if (Rooms, 4)// check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 4, 0);// Writes 0 to the 4bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           bitWrite(Rooms, 4, 1);// Writes 0 to the 4bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
          }
       break;

       case '6':
       Serial.print("Case 6 : ");//print case in serial Monitor
       if (Rooms, 5)//check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 5, 0);// Writes 0 to the 5bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output

           bitWrite(Rooms, 5, 1);// Writes 0 to the 5bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '7':
       Serial.print("Case 7 : ");//print case in serial Monitor
       if (Rooms, 6)//check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 6, 0);// Writes 0 to the 6bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           bitWrite(Rooms, 6, 1);// Writes 0 to the 6bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;

       case '8':
       Serial.print("Case 8 : ");//print case in serial Monitor
       if (Rooms, 7)//check if value is high
         { 
           Serial.println(" LOW"); //print LOW to serial monitor, changed state of output
           bitWrite(Rooms, 7, 0);// Writes 0 to the 7bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         } 
       else
         {
           Serial.println(" HIGH");//print HIGH to serial monitor, changed state of output
           bitWrite(Rooms, 7, 1);// Writes 0 to the 7bit of the Rooms word
           digitalWrite(latchPin, LOW);// So the LED's dont change as bits get shifted
           shiftOut(dataPin, clockPin, MSBFIRST, Rooms);// Send the Rooms word to the pins of the Shift Register
           digitalWrite(latchPin, HIGH); // Turn the Latch Pin HIGH so the LED's will light up
         }
       break;
      }
    }
  }

how ever even with this new code I am getting the same issue. Some times when I press a button to turn on the corresponding light a different light or two will come on. also sometime as I press buttons all the lights will flicker for a brief second. Could this mean my Shift register is fried?

I only looked fairly quickly but you have this line:

boolean Rooms = B00000000;

If you were to have kept the 8 variables, one variable for each room’s state, then those variables could be booleans. But now you use a singe variable to store the 8 rooms states so it needs to be at least a byte. I’m not sure what the compiler does when you declare it a boolean and use it as a byte. So try this first:

byte Rooms = 0;

…and see what happens. Also are the prints showing that the button presses are being properly decoded and saved ? That is, that they do what you said they should do above. If the prints are still goofy like they were before then the above declaration is most likely your problem. If the presses all look proper and do their LOW, HIGH, LOW sequence then the problem is either in the code that sends data to the SR or in the SR itself.

hello, I tried changing that Boolean to byte and still getting the same problem. I am also noticing that now only my 1 button works. If I press any other button the pin will always stay low. If I press the one button it will go high, however after that no matter what I pressed everything stays at its current state. Here is the example of the serial monitor:

Case 4 :  LOW
Case 4 :  LOW
Case 4 :  LOW
Case 3 :  LOW
Case 3 :  LOW
Case 3 :  LOW
Case 3 :  LOW
Case 2 :  LOW
Case 2 :  LOW
Case 2 :  LOW
Case 1 :  HIGH
Case 1 :  HIGH
Case 1 :  HIGH
Case 1 :  HIGH

It is still recognizing all button pushes but just not shifting out to the shift register.

I tested the shift register using a simple hello world code to count in binary up to 256 and it works no problem.

Let’s do a recap here.

  1. When you press a button on the keypad is it always getting recognized as a button pressed ?

  2. If it is recognized above, is it always recognized properly ? That is, push a 3 and the prints show a 3 was pushed. Push a 6 and it’s a 6 that’s recognized ?

  3. You’ve changed the Rooms variable from a boolean to a byte ?

  4. You’re using the Rooms variable and extracting the correct bit from it for the key pressed.

— BZZZZ mebbe not. See below.

  1. You’re storing the new, desired state of the room in the proper bit of the Rooms variable.

What I see in the code is this :

if(Rooms, 0)

…which is different from what I think it should be. See my prior post.

if(bitRead(Rooms, 0)) // check if value is high

If the code you’re using is the same as the 1’st code box above (but w/boolean to byte error fixed) then you are not extracting the proper bit from the Rooms variable. See the 2’nd code box above.

That was my issue and it is working perfectly now for what I wanted. My overall project will be to control a 12V lighting system by an arduino button pad. My next step is connecting the outputs to the relays and the lights. I thought the statement

if(Rooms,0)

check if bit zero of the rooms variable is high but I guess not. do you know what that code does?

Thanks again for your help the past couple of days. Hopefully I can eventually be fluent in the coding like you are.

k_rawn:
Hopefully I can eventually be fluent in the coding like you are.

Hopefully you can be fluent like a real software person is ! I code like an orangutan using 2 of it’s toes to type while being easily distracted by a yellow banana on a string just out of reach. I find people’s mistakes only because I made the same ones just last week. My wife was a real SW person; my coding attempts often made her cry … or laugh hysterically … which made me cry.

And the tears of an orangutan … they are large indeed ! :mrgreen: