/*
Wokwi | questions
Issue with shift register and microswitch
Krilly December 28, 2025 at 1:58 AM
*/
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#include "ShiftIn.h"
#include <vector>
int LED_PIN = 12;
int const LED_COUNT = 60;
int PL = 33;
int CLK = 32;
int CE = 25;
int DATA = 26;
int buzzer = 14;
const int numOfRegisters = 1;
ShiftIn<numOfRegisters> shift;
void setup()
{
Serial.begin(9600);
shift.begin(PL, CE, DATA, CLK);
}
std::vector<int> getCurrentStates()
{
std::vector<int> states;
for (int i = 0; i < 8 * numOfRegisters; i++)
{
int bitVal = shift.state(i) ? 1 : 0;
Serial.print(bitVal); // read single bit
states.push_back(bitVal);
}
Serial.println();
return states;
}
void loop()
{
if (shift.update())
{
//digitalWrite(buzzer, HIGH);
tone(buzzer, 1000);
delay(1000);
//digitalWrite(buzzer, LOW);
noTone(buzzer);
getCurrentStates();
}
getCurrentStates();
delay(1000);
}
60 WS2812 LEDs might need 3.6 amps!