#define SEG_COUNT 7
const int firstSeg = 2;
byte numberSegments[16] = {
0b11000000, //0
0b11111001, //1
0b10100100, //2
0b10110000, //3
0b10011001, //4
0b10010010, //5
0b10000010, //6
0b11111000, //7
0b10000000, //8
0b10010000, //9
0b10001000, //A
0b10000011, //b
0b11000110, //C
0b10100001, //d
0b10000110, //E
0b10001110 //F
};
byte pos = 1;
int lastButton = LOW;
int currButton = LOW;
void setup() {
for (int i = 0; i < SEG_COUNT; i++)
{
pinMode(firstSeg + i, OUTPUT);
digitalWrite(firstSeg + i, bitRead(numberSegments[0], i));
}
pinMode(1, INPUT_PULLUP);
}
void loop() {
static unsigned long timer;
if(timer + 50 > millis()) return;
currButton = digitalRead(1);
if(lastButton == HIGH && currButton == LOW)
{
for(int i = 0; i < SEG_COUNT; i++)
{
digitalWrite(firstSeg + i, bitRead(numberSegments[pos], i));
}
pos = pos == 15 ? 0 : ++pos;
}
lastButton = currButton;
timer = millis();
}