Pages

Friday, 11 January 2019

ESP32-SEVEN SEGMENT DISPLAYS

ESP32-SEVEN SEGMENT DISPLAYS

Aim:
Interfacing ESP32-Microcontroller with seven segment display, to display the numbers.
Hardware Required:
ESP32-Microcontroller development board
Connections:


Pin Mapping:
A
I04
B
I012
C
I033
D
I032
E
I025
F
I026
DP
I05
D1
GND

Program:
void setup()
{
  // define pin modes
  
pinMode(4,OUTPUT); //Set pin D2-D9 as input pins
pinMode(12,OUTPUT);
pinMode(33,OUTPUT);
pinMode(32,OUTPUT);
pinMode(25,OUTPUT);
pinMode(26,OUTPUT);
pinMode(27,OUTPUT);
pinMode(5,OUTPUT);
 
}
 
void loop() 
{
  // print 0
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
 // print 1
  
  {
   digitalWrite(4,HIGH);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
 // print 2
{
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,HIGH);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,HIGH);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
 
  // print 3
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW); 
   delay(1000);
  }
  // print 4
  {
   digitalWrite(4,HIGH);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 5
  {
   digitalWrite(4,LOW);
   digitalWrite(12,HIGH);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);  
   delay(1000);
  }
  // print 6
  {
   digitalWrite(4,LOW);
   digitalWrite(12,HIGH);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 7
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 8
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 9
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW); 
   delay(1000);
  } 
}




No comments:

Post a Comment