Advertisement
granteeric

Untitled

Apr 28th, 2020
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int tabValue[10] = {
  2.   0b00111111,   //0
  3.   0b00000110,   //1
  4.   0b01011001,   //2
  5.   0b01001111,   //3
  6.   0b01100110,   //4
  7.   0b01101101,   //5
  8.   0b01111101,   //6
  9.   0b01000111,   //7
  10.   0b01111111,   //8
  11.   0b01101111    //9
  12. };
  13.  
  14. int tabPort[7]={
  15.   0,    //PORTD0 ou RX+ uno         //Segment A
  16.   1,    //PORTD1 ou TX+ uno         //Segment B
  17.   2,    //PORTD2 ou digital2  uno   //Segment C
  18.   3,    //PORTD3 ou digital3  uno   //Segment D
  19.   4,    //PORTD4 ou digital4  uno   //Segment E
  20.   5,    //PORTD5 ou digital5  uno   //Segment F
  21.   6    //PORTD6 ou digital6  uno   //Segment G
  22. };
  23.  
  24.  
  25. void setup() {
  26.   activeOutputPort();
  27. }
  28.  
  29. void loop() {
  30.   for(int i = 0 ; i <10 ; i++){
  31.     afficheNumero(i);  
  32.     delay(2000);
  33.   }
  34. }
  35.  
  36. void afficheNumero(int numero){
  37.   for(int i = 6 ; i >= 0 ; i--){
  38.     ( (tabValue[numero] & (1 << i )) > 0 ) ? digitalWrite(i,HIGH) : digitalWrite(i,LOW);
  39.   }
  40. }
  41.  
  42. void activeOutputPort(){
  43.   for(int i = 0 ; i < 7 ; i++){
  44.     pinMode(tabPort[i],OUTPUT);
  45.     digitalWrite(tabPort[i],LOW);
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement