Pesquisar neste blog

15/04/2020

Programa 22 Contador

Contador com Arduino





Código
,
int numero[10][7] = {
  {1,1,1,1,1,1,0},//0
  {0,1,1,0,0,0,0},//1
  {1,1,0,1,1,0,1},//2
  {1,1,1,1,0,0,1},//3
  {0,1,1,0,0,1,1},
  {1,0,1,1,0,1,1},
  {1,0,1,1,1,1,1},
  {1,1,1,0,0,0,0},
  {1,1,1,1,1,1,1},
  {1,1,1,1,0,1,1},//9
  };

const int segmentos[8] = {2,3,4,5,6,7,8,9};//pinos de saída

void setup() {
  // put your setup code here, to run once:
  for(int i = 0; i <= 6; i++){
    pinMode(segmentos[i], OUTPUT);//liga o led do vetor
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int i = 0; i <= 9; i++){
    mostraNumero(i);
    delay(500);
  }
}

void mostraNumero(int valor){
  int pino = 2;
  for(int i = 0; i < 7; i++){
    digitalWrite(pino, numero[valor][i]);//fixa na linha e aciona os bits
    pino++;
  }
}

Nenhum comentário: