Skip to content

Instantly share code, notes, and snippets.

@artob
Last active February 20, 2020 13:38
Show Gist options
  • Save artob/9a0e3cf053a95051120020292b2414a6 to your computer and use it in GitHub Desktop.
Save artob/9a0e3cf053a95051120020292b2414a6 to your computer and use it in GitHub Desktop.
int pins[] = {11, 10, 9, 8, 7, 6, 5, 4};
void setup() {
for (int i = 0; i < 7; i++) {
pinMode(pins[i], OUTPUT);
}
}
int number = 0;
void loop() {
setNumber();
delay(1000);
number = (number + 1) % 10;
}
void setNumber() {
for (int i = 0; i < 7; i++) {
if (bitRead(numbers[number], 7 - i) == HIGH) {
digitalWrite(pins[i], HIGH);
}
else {
digitalWrite(pins[i], LOW);
}
}
}
byte numbers[10] = { B11111100, // 0
B01100000, // 1
B11011010, // 2
B11110010, // 3
B01100110, // 4
B10110110, // 5
B10111110, // 6
B11100000, // 7
B11111110, // 8
B11110110 // 9
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment