+88013 1284 4142 # 7 SEGMENT DISPLAY TUTORIAL WITH CODE IN ENGLISH |WITH ARDUINO BOARD | DOIT PROJECT

Today I am look at a single digit seven segment display. Then show you how it’s work.

So, this is our diagram. This is arduino board. This is breadboard. We need eight resistors. The resistors we took are 220 ohm. And obviously a 7 segments display.

Let’s start our circuit wiring.

Firstly take a wire and connect in pin 3. Which is connect wire for 7 segments B and plug into the digital pin 6. We select the color of wire is grey.

Followed by the next we take a wire for segment A and plug in the next pin in line on the Uno and this is pin 3. We select the color of wire is purple.

Similarly we plug the wires for segment C, d, E, F, G into the pin 4, 3, 2, 8 and 9 and the code that drafted for you is based upon this pin configuration that i’am setting up.

So, this is our seven segment display. (a, b, c, d, e,

f, g and the dot) is value of this display. They are our wiring system in our circuit.

The hole wiring system as same as i show you in first diagram. For power on the arduino board by connecting it to your computer using the USB cable. Before we work on our code make sure you download the arduino software. You can find the circuit codes link and arduino

### So, there are our code,

int A = 7;   //Defines all pins on the Arduino Uno board in order of connection.

int B = 6;

int C = 4;  // DOT is pin 5, not used in this example.

int D = 3;

int E = 2;

int F = 8;

int G = 9;

byte num0 = 0x3F;  //Hexadecimal format based upon the A-G, 0-9 Chart in excel and the wiring      // of the segment (refer to the on/off table image below).

byte num1 = 0x06;

byte num2 = 0x5B;

byte num3 = 0x4F;

byte num4 = 0x66;

byte num5 = 0x6D;

byte num6 = 0x7D;

byte num7 = 0x07;

byte num8 = 0x7F;

byte num9 = 0x6F;

void on(byte num)   // This function turns on the correct pins to display numbers passed to it         // through the variable “num”.

{

int result = bitRead(num, 0);  // Read the first binary entry in num and stores it in result.

if (result == 1)  // Check to see if this segment should be on.

{digitalWrite(A, HIGH);}   // Turns on the segment.

else   // Otherwise, it turns it off.

{digitalWrite(A, LOW);}  // Turns segment off.

result = bitRead( num, 1);  // Same thing for the 6 remaining segments.

if (result == 1)

{digitalWrite(B, HIGH);}

else

{digitalWrite(B, LOW);}

if (result == 1)

{digitalWrite(C, HIGH);}

else

{digitalWrite(C, LOW);}

if (result == 1)

{digitalWrite(D, HIGH);}

else

{digitalWrite(D, LOW);}

if (result == 1)

{digitalWrite(E, HIGH);}

else

{digitalWrite(E, LOW);}

if (result == 1)

{digitalWrite(F, HIGH);}

else

{digitalWrite(F, LOW);}

if (result == 1)

{digitalWrite(G, HIGH);}

else

{digitalWrite(G, LOW);}

}

void setup() {       // Our setup routine

pinMode(A, OUTPUT); // Making all pins outputs

pinMode(B, OUTPUT);

pinMode(C, OUTPUT);

pinMode(D, OUTPUT);

pinMode(E, OUTPUT);

pinMode(F, OUTPUT);

pinMode(G, OUTPUT);

pinMode(10,OUTPUT);

}

void loop() {   // Loops forever

on(num0);   // Passing “num0” to the function  “on()” defined above to display “0”

delay(1000);   // Delay for 1 second to see the “0”

on(num1);  // Change to “1”

delay(1000);

on(num2);

delay(1000);

on(num3);

delay(1000);

on(num4);

delay(1000);

on(num5);

delay(1000);

on(num6);

delay(1000);

on(num7);

delay(1000);

on(num8);

delay(1000);

on(num9);

delay(1000);

}

First of all integer define the pins value on the arduino board. As example we connect the A segment with pin 7. So, the value of a segment is 7.

The code in the setup part of the program tells us the arduino that pins A, B, C, D, E, F, G AND output. In the void loop it tells us the function of number. The segments turn on at a time with one thousand million second delay between each of them turning on. Let’s see how it’s work.

You can see the 7 segment display start countdown 0-9. So, this is our 7 segment display project.