#define COUNT 7
const int sevseg_a = 2;
byte num_segments[16] = { 0b10100000,
0b11111001,
0b11000100,
0b11010000,
0b10011001,
0b10010010,
0b10000010,
0b11111000,
0b10000000,
0b10010000,
0b10001000,
0b10000011,
0b10100110,
0b11000001,
0b10000110,
0b10001110 };
boolean segment;
int mask = 0;
int num = 0;
int lastButton = LOW;
int curButton = LOW;
const int button = 12;
void setup() {
for (int i = sevseg_a; i < COUNT + sevseg_a; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}
pinMode(button, INPUT);
digitalWrite(button, HIGH);
}
int debounce (int last) {
int current = digitalRead(button);
if (last != current) {
delay(10);
current = digitalRead(button);
}
return current;
}
void loop() {
curButton = debounce(lastButton);
if (lastButton == HIGH && curButton == LOW) {
mask = num_segments[num];
for (int i = 0; i < COUNT; i++) {
segment = bitRead(mask, i);
digitalWrite(i + sevseg_a, segment);
}
num++;
if (num > 15) {
num = 0;
}
}
lastButton = curButton;
}