1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| int variable= 15325;
const int Affich_A = 4; // Cinq afficheurs multiplexés par un 4028 //port D Arduino
const int Affich_B = 6;
const int Affich_C = 7;
const int Seg_A = 8; // Sept segments commandés par un 4513 // Port B Arduino
const int Seg_B = 9;
const int Seg_C = 10;
const int Seg_D = 11;
void setup() {
pinMode (Affich_A,OUTPUT);
pinMode (Affich_B,OUTPUT);
pinMode (Affich_C,OUTPUT);
pinMode (Seg_A,OUTPUT);
pinMode (Seg_B,OUTPUT);
pinMode (Seg_C,OUTPUT);
pinMode (Seg_D,OUTPUT);
digitalWrite(Affich_A,0);
digitalWrite(Affich_B,0);
digitalWrite(Affich_C,0);
digitalWrite(Seg_A,0);
digitalWrite(Seg_B,0);
digitalWrite(Seg_C,0);
digitalWrite(Seg_D,0);
}
void loop() {
unit();
dizaine();
centaine();
millier();
diz_millier();
}
void unit(){ variable = variable % 10;
PORTD &= B00000000; // reset afficheur dizaine de millier equivaut à l' allumage afficheur unité
PORTB |= B00000001; // pour test, afiche 1 sur l'afficheur unité
delay(6);
PORTB &= B00000000; // reset affichage
}
void dizaine(){ // pas besoin de resetter l'afficheur unité car deja a 0
PORTD |= B00010000; // allumage afficheur dizaine
PORTB |= B00000010; // pour test, affiche 2 sur afficheur dizaine
delay(6);
PORTB &= B00000000; //reset affichage
}
void centaine(){
PORTD &= B00000000; // reset afficheur dizaine
PORTD |= B01000000; // allumage afficheur centaine
PORTB |= B00000011; // pour test, affiche 3 sur afficheur dizaine
delay(6);
PORTB &= B00000000; // reset affichage
}
void millier(){
PORTD &= B00000000; // reset afficheur centaine
PORTD |= B01010000; // allumage afficheur millier
PORTB |= B00000100; // pour test, affiche 4 sur afficheur centaine
delay(6);
PORTB &= B00000000; // reset affichage
}
void diz_millier(){
PORTD &= B00000000; // reset afficheur centaine
PORTD |= B10000000; // allumage afficheur dizaine de millier
PORTB |= B00000101; // pour test, affiche 5 sur afficheur centaine
delay(6);
PORTB &= B00000000; // reset affichage
} |
Partager