#include <SevSeg.h>
SevSeg sevseg; // Create a SevSeg object
const int buttonUpPin = 11; // Pin for count-up button
const int buttonDownPin = 10; // Pin for count-down button
int count = 0; // Variable to store the count value
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
byte numDigits = 1; // Number of digits in your display
byte digitPins[] = {2}; // Pin for segment A
byte segmentPins[] = {3, 4, 5, 6, 7, 8, 9}; // Pins for common cathode digits 1, 2, 3, 4
sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
pinMode(buttonUpPin, INPUT_PULLUP);
pinMode(buttonDownPin, INPUT_PULLUP);
}
void loop() {
// Check count-up button
if (digitalRead(buttonUpPin) == LOW) {
count++;
delay(250); // Debounce delay
}
// Check count-down button
if (digitalRead(buttonDownPin) == LOW) {
count--;
delay(250); // Debounce delay
}
// Display the count on the 7-segment display
sevseg.setNumber(count);
sevseg.refreshDisplay();
if(count>2)
digitalWrite(12, HIGH);
else
digitalWrite(12, LOW);
if(count>5)
digitalWrite(13, HIGH);
else
digitalWrite(13, LOW);
delay(10); // Optional delay for stability
}