Skip to content

Instantly share code, notes, and snippets.

@zxmarcos
Created May 20, 2015 18:03
Show Gist options
  • Select an option

  • Save zxmarcos/44055159ec56e9cb7159 to your computer and use it in GitHub Desktop.

Select an option

Save zxmarcos/44055159ec56e9cb7159 to your computer and use it in GitHub Desktop.
int numeros[10][7] =
{
// A B C D E F G
{ 1, 1, 1, 1, 1, 1, 0 }, // Num 0
{ 0, 1, 1, 0, 0, 0, 0 }, // Num 1
{ 1, 1, 0, 1, 1, 0, 1 }, // Num 2
{ 1, 1, 1, 1, 0, 0, 1 }, // Num 3
{ 0, 1, 1, 0, 0, 1, 1 }, // Num 4
{ 1, 0, 1, 1, 0, 1, 1 }, // Num 5
{ 1, 0, 1, 1, 1, 1, 1 }, // Num 6
{ 1, 1, 1, 0, 0, 0, 0 }, // Num 7
{ 1, 1, 1, 1, 1, 1, 1 }, // Num 8
{ 1, 1, 1, 0, 0, 1, 1 }, // Num 9
};
int portas[7] = {
// A B C D E F G
6,5,2,3,4,7,8
};
void exibir_numero(int num)
{
if (num < 10) {
int i = 0;
while (i < 7) {
int porta = portas[i];
if (numeros[num][i] == 1) {
// Acender o LED
digitalWrite(porta, HIGH);
} else {
// Apagar o LED
digitalWrite(porta, LOW);
}
i++;
}
}
}
void setup() {
int i = 2;
while (i < 9) {
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
i++;
}
}
void loop() {
int i = 0;
while (i < 10) {
exibir_numero(i);
delay(100);
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment