Pages

Wednesday, 16 March 2022

Seven Segment Displays

 

EXPERIMENT NO 3

Seven Segment Displays

 

Aim:

Interfacing ESP32-Microcontroller with seven segment display.

Description:

To display numbers in the seven segment display.

Hardware Required:

ESP32-Microcontroller Development board and FRC Cables.

 




 Procedure:

1.      Connect P2 port and SV4 (Data) port and connect P3 port and SV3 (Select) port using FRC cable as shown above.

2.      Connect the USB cable to the board.

3.      Open Arduino IDE .Select DOIT ESP32 DEVKIT V1 in boards and select COM port.

4.      Now Write the program, verify and Upload it.

5.      Now you can see that number starts displaying on the seven segments on the ESP32 development board.

 

Program:

const int sel1=27, sel2=14, sel3=12, sel4=13;                         //initializing selection pins -Port P3

const int a=16 ,b=17, c=5, d=18, e=19, f=21, g=22, dp=23;  //initializing data pins -Port P2

void setup()

{

pinMode(sel1,OUTPUT);                //declaring Selection Pins as output

pinMode(sel2,OUTPUT);

pinMode(sel3,OUTPUT);

pinMode(sel4,OUTPUT);

 

 digitalWrite(sel1,LOW);               //selecting all 4 digits of 7-Segment display by making it LOW

 digitalWrite(sel2,LOW);

 digitalWrite(sel3,LOW);

 digitalWrite(sel4,LOW);

 

pinMode(a,OUTPUT);                 //declaring data pins as output

pinMode(b,OUTPUT);

pinMode(c,OUTPUT);

pinMode(d,OUTPUT);

pinMode(e,OUTPUT);

pinMode(f,OUTPUT);

pinMode(g,OUTPUT);

pinMode(dp,OUTPUT);

delay(100);

}

 void loop()

{

   // print 0

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,HIGH);

   digitalWrite(dp,LOW);

   delay(2000); 

  // print 1

   digitalWrite(a,HIGH);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,HIGH);

   digitalWrite(dp,HIGH);

   delay(2000);

   

  // print 2

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,HIGH);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,HIGH);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

  

// print 3

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

   

  // print 4

   digitalWrite(a,HIGH);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

  // print 5

   digitalWrite(a,LOW);

   digitalWrite(b,HIGH);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

   

  // print 6

   digitalWrite(a,LOW);

   digitalWrite(b,HIGH);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

  // print 7

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,HIGH);

   digitalWrite(dp,HIGH);

   delay(2000);

   

  // print 8

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

   // print 9

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);  

 }

 

 

No comments:

Post a Comment