#include <SevSeg.h>
SevSeg sevseg1;
SevSeg sevseg2;
const int tombolPlus1Pin = 2;
const int tombolMinus1Pin = 3;
const int tombolPlus2Pin = 4;
const int tombolMinus2Pin = 5;
const int tombolResetPin = A12;
int score1 = 0;
int score2 = 0;
void setup() {
byte numDigits = 2;
byte digitPins1[] = {6, 7};
byte segmentPins1[] = {8, 9, 10, 11, 12, 13, A0, A1};
byte digitPins2[] = {A2, A3};
byte segmentPins2[] = {A4, A5, A6, A7, A8, A9, A10, A11};
sevseg1.begin(COMMON_CATHODE, numDigits, digitPins1, segmentPins1);
sevseg2.begin(COMMON_CATHODE, numDigits, digitPins2, segmentPins2);
pinMode(tombolPlus1Pin, INPUT_PULLUP);
pinMode(tombolMinus1Pin, INPUT_PULLUP);
pinMode(tombolPlus2Pin, INPUT_PULLUP);
pinMode(tombolMinus2Pin, INPUT_PULLUP);
pinMode(tombolResetPin, INPUT_PULLUP);
sevseg1.setNumber(score1);
sevseg2.setNumber(score2);
sevseg1.refreshDisplay();
sevseg2.refreshDisplay();
}
void loop() {
if (digitalRead(tombolPlus1Pin) == LOW) {
delay(200);
score1++;
}
if (digitalRead(tombolMinus1Pin) == LOW) {
delay(200);
score1--;
}
if (digitalRead(tombolPlus2Pin) == LOW) {
delay(200);
score2++;
}
if (digitalRead(tombolMinus2Pin) == LOW) {
delay(200);
score2--;
}
// Membaca status tombol reset
if (digitalRead(tombolResetPin) == LOW) {
delay(200); // Delay untuk menghindari bouncing
(score1) = 0;
(score2) = 0;
}
sevseg1.setNumber(score1);
sevseg2.setNumber(score2);
sevseg1.refreshDisplay();
sevseg2.refreshDisplay();
}