#include "SevSeg.h"
SevSeg sevseg; //Initiate a seven segment controller object
// bytes are half the size of int's, but restricted to a max value of 255
byte buttonpin = 13;
bool state = 0;
bool current=0;
bool prev=0;
int i=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(buttonpin, INPUT);
// initialize the digital pins as outputs.
byte numDigits = 4;
byte digitPins[] = {9, 10, 11, 12};
byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, A0};
bool resistorsOnSegments = 0;
// variable above indicates that 4 resistors were placed on the digit pins.
// set variable to 1 if you want to use 8 resistors on the segment pins.
sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
}
void loop() {
// put your main code here, to run repeatedly:
current=digitalRead(buttonpin);
while(current==HIGH){
current=digitalRead(buttonpin);
if(current==LOW)
{
state=!state;
//Serial.println(state);
prev=current;
i=i+1;
}
delay(100);
}
sevseg.setNumber(i, 4);
sevseg.refreshDisplay(); // Must run repeatedly
delay(1);
}