const int dataPin = 8;
const int latchPin = 10;
const int clockPin = 11;
int dataArray[7] = {
0B01111111,
0B10111111,
0B11011111,
0B11101111,
0B11110111,
0B11111011,
};
int count = -1;
int buttonPin = 13;
int buzzerPin = 12;
int buttonState;
bool check = true;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(dataPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
count ++;
count = count%2;
}
if(count == 0 && check){
for (int index = 0; index < 7; index++) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, dataArray[index]);
digitalWrite(latchPin, HIGH);
delay(1000);
}
check = false;
}
else if(count == 1) {
tone(buzzerPin, 100);
delay(1000);
noTone(buzzerPin);
count = -1;
check = true;
}
}