7 Segment 4 Digits Display Count Up Number - TANN THONA

Department of Telecommunication and Electronic Engineering

Hot

Post Top Ad

Tuesday, December 4, 2018

7 Segment 4 Digits Display Count Up Number

7 Segment 4 Digits Display

1. Objective

The objective of this project is talk about, how to use 7 segment 4 digits and display count up from 0 to 9999.

2. Electronic Requirement

  • Arduino UNO
  • USP Cable
  • 7 Segment 4 digits (Cathode Type) 
  • Breadboard
  • Electronic Wire
  • Resistor x4 (330Ohm or 220Ohm)
    • Arduino pin 5 --> R1 --> 7 Segment D1
    • Arduino pin 4 --> R2 --> 7 Segment D2
    • Arduino pin 3 --> R3 --> 7 Segment D3
    • Arduino pin 2 --> R4 --> 7 Segment D4

    3. How to Build it?

     The first build circuit like below on Fig 1.1 automatic count up number.

    Fig 1. 7 segment 4 digits display automatic count up number 0 to 9999
    // Write code by Tann Thona (25/02/2017), Adviser: Chann Tola
    int PIN_A = 12;
    int PIN_B = 11;
    int PIN_C = 10;
    int PIN_D = 9;
    int PIN_E = 8;
    int PIN_F = 7;
    int PIN_G = 6;
    int DL4 = 5;
    int DL3 = 4;
    int DL2 = 3;
    int DL1 = 2;
    int i = 0;
    int j = 0;
    int n = 0;
    int k = 0;
    int h = 0;
    int Arduino_Pins[7] = {PIN_A, PIN_B, PIN_C, PIN_D, PIN_E, PIN_F, PIN_G}; // an array of pin numbers to which LEDs
    int Segment_Pins[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}, // 4
    {1,0,1,1,0,1,1}, // 5
    {1,0,1,1,1,1,1}, // 6
    {1,1,1,0,0,0,0}, // 7
    {1,1,1,1,1,1,1}, // 8
    {1,1,1,1,0,1,1}, // 9
    };
    int DELAY = 1;
    int TIME = 0;
    void digit4()
    {
    digitalWrite(DL1,0);
    digitalWrite(DL2,1);
    digitalWrite(DL3,1);
    digitalWrite(DL4,1);
    for(j=0;j<7;j++) {
    digitalWrite(Arduino_Pins[j],Segment_Pins[i][j]);
    }
    delay(DELAY);
    }
    //=============================
    void digit3()
    {
    digitalWrite(DL1,1); // change 1 to 0 and 0 to 1 (for 7segment anoth type)
    digitalWrite(DL2,0);
    digitalWrite(DL3,1);
    digitalWrite(DL4,1);
    for(j=0;j<7;j++)
    {
    digitalWrite(Arduino_Pins[j],Segment_Pins[n][j]);
    } // end loop j
    delay(DELAY);
    }
    //==============================
    void digit2()
    {
    digitalWrite(DL1,1);
    digitalWrite(DL2,1);
    digitalWrite(DL3,0);
    digitalWrite(DL4,1);
    for(j=0;j<7;j++)
    {
    digitalWrite(Arduino_Pins[j],Segment_Pins[k][j]);
    } // end loop k
    delay(DELAY);
    }
    //==============================
    void digit1()
    {
    digitalWrite(DL1,1);
    digitalWrite(DL2,1);
    digitalWrite(DL3,1);
    digitalWrite(DL4,0);
    for(j=0;j<7;j++)
    {
    digitalWrite(Arduino_Pins[j],Segment_Pins[h][j]);
    } // end loop j
    delay(DELAY);
    }
    void setup()
    {
    // put your setup code here, to run once:
    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);
    pinMode(DL1, OUTPUT);
    pinMode(DL2, OUTPUT);
    pinMode(DL3, OUTPUT);
    pinMode(DL4, OUTPUT);

    }
    void loop()
    {

    for(i=0;i<10;i++)
    {
    for(TIME=0;TIME<=250;TIME++)// Simulation (TIME=0;TIME<=250;TIME++)
    {
    digit4();
    digit3();
    digit2();
    digit1();
    //delay(1);
    }
    // Condition Count Up

    if(i==9)
    {
    n++;
    //----------------
    if(n>9)
    {
    k++;
    //----------------
    if(k>9)
    {
    h++;
    //----------------
    if(h>9)
    {
    h = 0;
    } // end if(h>9)
    } // end if(k==9)
    //----------------
    if(k>9)
    {
    k = 0;
    }
    } // end if(n==9)
    //----------------
    if(n>9)
    {
    n = 0;
    } // end if (n>9)
    } // end if (i==9)

    } // end time

    } // End Void Loop


    4. Result

    Now we get a result that 7 segment 4 digits  display are started from 0 to 9999 with count up one by one per second in automatically like video below.








    Royal University of Phnom Penh
    Faculty of Engineering
    Dep. Telecommunication and Electronic Engineering

    Group Member:
    1. Tann Thona

    2. Thach Soveasna
    3. Chhoy Noreath
    4. Neth Channa
    5. Mok Vira 


    Instructor: Prof. Chann Tola
    Date: 25 February 2017

    No comments:

    Post a Comment

    Post Top Ad