#include "SevSeg.h"
SevSeg sevseg;
//button: LOW when button is pressed
//HIGH when buton not pressed
const int btnPin = 10; //pin number for the button
int buttonState = 0; // current state of the button
int lastButtonState = LOW; // previous state of the button
void setup() {
// put your setup code here, to run once:
byte numOfDigits = 1;
byte digitPins[] = {};
byte segmentPin[] = {2, 3, 4, 5, 6, 7, 8, 9};
bool resistorsOnSegments = true;
//setting up the 7 segment display, initialising the common pin,
//number of digits to display, and the pins that decided to use
byte hardwareConfig = COMMON_CATHODE;
sevseg.begin(hardwareConfig, numOfDigits, digitPins, segmentPin, resistorsOnSegments);
sevseg.setBrightness(90);
//setting up the button
pinMode(btnPin, INPUT_PULLUP);
Serial.begin(9600);
lastButtonState = LOW;
}
void loop() {
// put your main code here, to run repeatedly:
static int deciSeconds = 0;
buttonState = digitalRead(btnPin);
if(buttonState == HIGH)
{
buttonState = LOW;
}
else
{
buttonState = HIGH;
}
if(buttonState == HIGH)
{
for(int i = 0; i < 10; i++)
{
sevseg.setNumber(i);
delay(1000);
sevseg.refreshDisplay();
}
}
else
{
sevseg.refreshDisplay();
}
}