const int segPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
const int digitPins[] = {5, 4, 3, 2};
const int potPin = A0;
const byte charMasks[] = {
0b11111100,
0b01100000,
0b11011010,
0b11110010,
0b01100110,
0b10110110,
0b10111110,
0b11100000,
0b11111110,
0b11110110,
0b11101110,
0b00111110,
0b10011100,
0b01111010,
0b10011110,
0b10001110,
0b11110110,
0b00101110,
0b00001100,
0b01111000,
0b10001110,
0b00011100,
0b11101100,
0b00101010,
0b11111100,
0b11001110,
0b11100110,
0b00001010,
0b10110110,
0b00011110,
0b01111100,
0b01111100,
0b01111100,
0b01101110,
0b01110110,
0b11011010
};
const int totalChars = sizeof(charMasks);
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(segPins[i], OUTPUT);
}
for (int i = 0; i < 4; i++) {
pinMode(digitPins[i], OUTPUT);
digitalWrite(digitPins[i], HIGH);
}
}
void loop() {
for (int c = 0; c < totalChars; c++) {
for (int i = 3; i >= 0; i--) {
for (int d = 0; d < 4; d++) {
digitalWrite(digitPins[d], HIGH);
}
digitalWrite(digitPins[i], LOW);
for (int s = 0; s < 8; s++) {
bool bitVal = bitRead(charMasks[c], 7 - s);
digitalWrite(segPins[s], bitVal);
}
int potValue = analogRead(potPin);
int delayTime = map(potValue, 0, 1023, 100, 3000);
delay(delayTime);
}
}
}