[source] exemple_arduinoDisplay7seg_cont.ino

postagem de conteudo sobre programação de microcontroladores avr e arduino
Post Reply
User avatar
Kodo no Kami
Admin
Admin
Posts: 725
Joined: Fri Jan 02, 2015 1:56 pm
Contact:

[source] exemple_arduinoDisplay7seg_cont.ino

Post by Kodo no Kami » Fri Sep 21, 2018 6:42 pm

exemplo contador display 7 segmento com arduino

Code: Select all

#define PIN_A 12
#define PIN_B 11  
#define PIN_C 10
#define PIN_D 9
#define PIN_E 8
#define PIN_F 7
#define PIN_G 6
#define TEMPO 1000 //ms

int cont = 0;

void kodo_apagar(){
  digitalWrite(PIN_A,LOW);
  digitalWrite(PIN_B,LOW);
  digitalWrite(PIN_C,LOW);
  digitalWrite(PIN_D,LOW);
  digitalWrite(PIN_E,LOW);
  digitalWrite(PIN_F,LOW);
  digitalWrite(PIN_G,LOW);
}

void setup() {
  pinMode(PIN_A,OUTPUT);
  pinMode(PIN_B,OUTPUT);
  pinMode(PIN_C,OUTPUT);
  pinMode(PIN_D,OUTPUT);
  pinMode(PIN_E,OUTPUT);
  pinMode(PIN_F,OUTPUT);
  pinMode(PIN_G,OUTPUT);

}

void loop() {
  if(cont > 9){
    cont = 0;
  }
  if(cont == 0){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_E,HIGH);
    digitalWrite(PIN_F,HIGH);
  }
  else if(cont == 0){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
  }
  else if(cont == 1){
    kodo_apagar();
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
  }
  else if(cont == 2){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_E,HIGH);
    digitalWrite(PIN_G,HIGH);
    
  }
  else if(cont == 3){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
 else if(cont == 4){
    kodo_apagar();
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_F,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
 else if(cont == 5){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_F,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
  else if(cont == 6){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_F,HIGH);
    digitalWrite(PIN_E,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
  else if(cont == 7){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
  }
  else if(cont == 8){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_D,HIGH);
    digitalWrite(PIN_E,HIGH);
    digitalWrite(PIN_F,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
  else if(cont == 9){
    kodo_apagar();
    digitalWrite(PIN_A,HIGH);
    digitalWrite(PIN_B,HIGH);
    digitalWrite(PIN_C,HIGH);
    digitalWrite(PIN_F,HIGH);
    digitalWrite(PIN_G,HIGH);
  }
  cont++;
  delay(TEMPO);
}
Image

que desagradavel ~ mirai kuriyama

Post Reply

Return to “AVR”