Shift register stops working after I send one piece of code with my arduino

137 Views Asked by At

I have been stuck with this problem for multiple days now and can't seem to find a fix. The problem is that after I send a command to my shift register it doesn't accept more commands. I'm using an arduino UNO with a 74HC595 shift register. The problem occurs in the manualOverWrite function.

uint8_t RFIDPinValues[] = { B00000101 };
sr.setAll(RFIDPinValues);
delay(4000);
uint8_t RFIDOffPinValues[] = { B00001000 };
sr.setAll(RFIDOffPinValues); 

When I run this piece of my code it turns on a relay(pin 0) and stops. All my arduino code keeps working except the shift register.

#include <SPI.h>
#include <ShiftRegister74HC595.h>

byte readCard[4];
String MasterTag0 = "*******"; 
String MasterTag1 = "********";
String tagID = "";

//declare arduino pins
int overWrite = 0;


// Create instances
const int numberOfShiftRegisters = 1; // number of shift registers attached in series
int serialDataPin = 11; 
int clockPin = 12; 
int latchPin = 8; 
ShiftRegister74HC595<numberOfShiftRegisters> sr(serialDataPin, clockPin, latchPin);

void setup() {
  Serial.begin(115200);
  Serial.println("Startup");

  // Initiating inputs
  pinMode(overWriteButton, INPUT);
   
  // set base state
  sr.setAllLow();
  
  uint8_t startValues[] = { B00001000 };
  sr.setAll(startValues);
}

void loop() {
   
  //ez to use vars
  overWrite = digitalRead(overWriteButton);
  
  manualOverWrite();
}


void manualOverWrite() {
  if(overWrite == HIGH) {
    uint8_t turnOnPinValues[] = { B00000101 };
    sr.setAll(turnOnPinValues);
    delay(5000);
    uint8_t turnOffPinValues[] = { B00001000 };
    sr.setAll(turnOffPinValues);
  }
  else {
    uint8_t turnOn2PinValues[] = { B00001000 };
    sr.setAll(turnOn2PinValues);
  }
}

My apologies for the mess https://mega.nz/file/NEYFiAAA#Rc4QUpv6cnL-_1NJJrjKe-IaInH_33wGJlHpGlVkySM

0

There are 0 best solutions below