Multiplexage 74HC95

7-Segment-Display-Arduino-Circuit

hs 74HC595-Shift-Register

  • Vcc
    Up to 6V (needs to be the same voltage as your microcontroller) – Usually 3.3 / 5v
  • QA to QH
    Shift Register Outputs.
  • SER:
    (Serial) Input for the next pin that gets shifted in.
  • SRCLK
    (Serial Clock) When this pin is pulled high, it will shift the register.
  • RCLK
    (Register Clock) Needs to be pulled high to set the output to the new shift register values, This must be pulled high directly after SRCLK has gone LOW again.
  • SRCLR
    (Serial Clear) Will empty the whole Shift Register if pulled LOW, must be pulled High to enable.
  • OE
    (Output Enable) This pin enables the output when tied to GND, & disabled when HIGH.

circuitDiagcircuit_tyc-365gwb ledgraphledgraph2

seg Afficheur_bb

Avec des résistances de 460 Ohms

Librairie :

https://github.com/Simsso/Shift-Register-74HC595-Arduino-Library

Pour modifier l’intensité lumineuse il suffit de relier la broche 13 du HC à une broche PWM de l’Arduino et faire varier la valeur de 0 à 255

pinMode(outputEnablePin, OUTPUT);

void setBrightness(byte brightness)

{  analogWrite(outputEnablePin, 255-brightness);}

https://learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/brightness-control

 //////////////  
 // Test d'un afficheur 7 segments à 4 chiffres  
 // Avec un interrupteur relié en PIN 22  
 ///////////////////////////////////////  
 #include <ShiftRegister74HC595.h>  
 const int SEG0 = 5;  
 const int SEG1 = 4;  
 const int SEG2 = 3;  
 const int SEG3 = 2;  
 const int numberOfShiftRegisters = 1; // number of shift registers attached in series  
 const int serialDataPin = 8; // DS  
 const int clockPin = 9; // SHCP  
 const int latchPin = 10; // STCP  
 ShiftRegister74HC595 sr (numberOfShiftRegisters, serialDataPin, clockPin, latchPin);  
 const int buttonPin = 22;   // the number of the pushbutton pin  
 int buttonState = 0, prevUpState = 0;  
 int nB = 0;  
 int tab[4];  
 //////////////////////////  
 void setup()  
 { Serial.begin(9600);  
  pinMode(SEG0, OUTPUT);  
  pinMode(SEG1, OUTPUT);  
  pinMode(SEG2, OUTPUT);  
  pinMode(SEG3, OUTPUT);  
  sr.setAllHigh(); // Eteinds all pins  
  // initialize the pushbutton pin as an input:  
  pinMode(buttonPin, INPUT);  
  Serial.println("Init...");  
 }  
 ///////////////  
 void loop() {  
  buttonState = digitalRead(buttonPin);  
  if (prevUpState != buttonState)       // has the state changed from  
  { // HIGH to LOW or vice versa  
   prevUpState = buttonState;  
   if (buttonState == HIGH)         // If the button was pressed  
   {  
    nB++;  
    tab[3] = nB % 10;  
    tab[2] = nB / 10;  
    tab[1] = nB / 100;  
    tab[0] = nB / 1000;  
    Serial.print("Nb=");  
    Serial.print(nB);  
    Serial.print(":");  
    Serial.print(tab[0]);  
    Serial.print(tab[1]);  
    Serial.print(tab[2]);  
    Serial.println(tab[3]);  
    //delay(50);  
   }  
  }  
  compte();  
 }  
 ///////////////  
 void compte()  
 {  
  for (int Digit = 1; Digit < 5; Digit++)  
  {  
   switch (Digit) {  
    case 1:  
     digitalWrite(SEG0, HIGH);  
     digitalWrite(SEG1, LOW);  
     digitalWrite(SEG2, LOW);  
     digitalWrite(SEG3, LOW);  
     Analyse(tab[0]);  
     break;  
    case 2:  
     digitalWrite(SEG0, LOW);  
     digitalWrite(SEG1, HIGH);  
     digitalWrite(SEG2, LOW);  
     digitalWrite(SEG3, LOW);  
     Analyse(tab[1]);  
     break;  
    case 3:  
     digitalWrite(SEG0, LOW);  
     digitalWrite(SEG1, LOW);  
     digitalWrite(SEG2, HIGH);  
     digitalWrite(SEG3, LOW);  
     Analyse(tab[2]);  
     break;  
    case 4:  
     digitalWrite(SEG0, LOW);  
     digitalWrite(SEG1, LOW);  
     digitalWrite(SEG2, LOW);  
     digitalWrite(SEG3, HIGH);  
     Analyse(tab[3]);  
     break;  
   }  
   delay(3);  
  }  
 }  
 void Analyse(int NbA) {  
  switch (NbA) {  
   case 1 :  
    un();  
    break;  
   case 2 :  
    deux();  
    break;  
   case 3 :  
    trois();  
    break;  
   case 4 :  
    quatre();  
    break;  
   case 5 :  
    cinq();  
    break;  
   case 6 :  
    six();  
    break;  
   case 7 :  
    sept();  
    break;  
   case 8 :  
    huit();  
    break;  
   case 9 :  
    neuf();  
    break;  
   default :  
    zero();  
    break;  
  }  
 }  
 ////////////  
 // LOW = Allumé  
 // HIGH = Eteinds  
 ///////////////  
 void un()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, HIGH);  
  sr.set(2, LOW);  
  sr.set(3, LOW);  
  sr.set(4, HIGH);  
  sr.set(5, HIGH);  
  sr.set(6, HIGH);  
  sr.set(7, HIGH);  
 }  
 void deux()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, LOW);  
  sr.set(2, LOW);  
  sr.set(3, HIGH);  
  sr.set(4, LOW);  
  sr.set(5, LOW);  
  sr.set(6, HIGH);  
  sr.set(7, LOW);  
 }  
 void trois()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, LOW);  
  sr.set(2, LOW);  
  sr.set(3, LOW);  
  sr.set(4, LOW);  
  sr.set(5, HIGH);  
  sr.set(6, HIGH);  
  sr.set(7, LOW);  
 }  
 void quatre()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, HIGH);  
  sr.set(2, HIGH);  
  sr.set(3, LOW);  
  sr.set(4, HIGH);  
  sr.set(5, HIGH);  
  sr.set(6, LOW);  
  sr.set(7, LOW);  
 }  
 void cinq()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, LOW);  
  sr.set(2, HIGH);  
  sr.set(3, LOW);  
  sr.set(4, LOW);  
  sr.set(5, HIGH);  
  sr.set(6, LOW);  
  sr.set(7, LOW);  
 }  
 void six()  
 { sr.setAllLow();  
  sr.set(0, HIGH);  
  sr.set(1, HIGH);  
  sr.set(2, HIGH);  
 }  
 void sept()  
 { sr.setAllHigh();  
  sr.set(0, HIGH);  
  sr.set(1, LOW);  
  sr.set(2, LOW);  
  sr.set(3, LOW);  
  sr.set(4, HIGH);  
  sr.set(5, HIGH);  
  sr.set(6, HIGH);  
  sr.set(7, HIGH);  
 }  
 void huit()  
 { sr.setAllLow();  
  sr.set(0, HIGH);  
 }  
 void neuf()  
 { sr.setAllLow();  
  sr.set(0, HIGH);  
  sr.set(5, HIGH);  
 }  
 void zero()  
 { sr.setAllLow();  
  sr.set(0, HIGH);  
  sr.set(7, HIGH);  
 }  

 

tab

Programmation
Affichage Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Héxadecimal
0 0 0 1 1 1 1 1 1 0x3F
1 0 0 0 0 0 1 1 0 0x06
2 0 1 0 1 1 0 1 1 0x5B
3 0 1 0 0 1 1 1 1 0x4F
4 0 1 1 0 0 1 1 0 0x66
5 0 1 1 0 1 1 0 1 0x6D
6 0 1 1 1 1 1 0 1 0x7D
7 0 0 0 0 0 1 1 1 0x07
8 0 1 1 1 1 1 1 1 0x7F
9 0 1 1 0 1 1 1 1 0x6F
A 0 1 1 1 0 1 1 1 0x77
B 0 1 1 1 1 1 0 0 0x7C
C 0 0 1 1 1 0 0 1 0x39
D 0 1 0 1 1 1 1 0 0x5E
E 0 1 1 1 1 0 0 1 0x79
F 0 1 1 1 0 0 0 1 0x71

Références :

http://circuits4you.com/2016/12/14/segment-display-interfacing-arduino/http://circuits4you.com/2016/12/14/segment-display-interfacing-arduino/

http://bildr.org/2011/02/74hc595/

https://www.instructables.com/id/Different-methods-of-driving-7-Segment-LED-display/

Publicités
Articles récents
Commentaires récents
fatima sur Bienvenue !
AdminDroid sur Bienvenue !
fatima sur Bienvenue !
Archives
Catégories
%d blogueurs aiment cette page :