//design a counter (0-9) uaing 7 segment and switch
//when switch is on count value increment to next
//when switch is off stay on same value
//do not use pins 34 35 36 39
//pins connection a32 b33 c25 d26 e27 f12 g14 dp13
int pins[] = {32, 33, 25, 26, 27, 12, 14};
int data[10][7] =
{
{0, 0, 0, 0, 0, 0, 1}, // 0
{1, 0, 0, 1, 1, 1, 1}, // 1
{0, 0, 1, 0, 0, 1, 0}, // 2
{0, 0, 0, 0, 1, 1, 0}, // 3
{1, 0, 0, 1, 1, 0, 0}, // 4
{0, 1, 0, 0, 1, 0, 0}, // 5
{0, 1, 0, 0, 0, 0, 0}, // 6
{0, 0, 0, 1, 1, 1, 1}, // 7
{0, 0, 0, 0, 0, 0, 0}, // 8
{0, 0, 0, 0, 1, 0, 0} // 9
};
const int switchPin = 18;
int INITIAL = 0;
int START;
int END = HIGH;
void setup() {
for (int x = 0; x < 7; x++) {
pinMode(pins[x], OUTPUT);
}
pinMode(switchPin, INPUT_PULLUP);
}
void loop() {
START = digitalRead(switchPin);
if (START == LOW && END == HIGH)
{
INITIAL = (INITIAL + 1) % 10;
}
for (int x = 0; x < 7; x++)
{
digitalWrite(pins[x], data[INITIAL][x]);
}
END = START;
delay(100);
}