4 Digital 7segment Display

3 years ago 1121
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments

Description

4 Digital 7segment Display

This article is the use of Arduino MEGA 2560 board to drive some of the color LED digital tube.All of the content is edit in the edit in the easyeda.com

Usually in the production , the 4-digital 7 segment LED display is a lot of advantages, in the network, we can see many users in the difficult search related projects. Here we come to design a Arduino 7 digital four-segment LED display program. The 4 digital led is a collection in one package, the peripheral pin is very few, the connection is simple. The circuit schematic diagram based on the easyeda.com website design, easyeda can find the design of the source file, you can change after you as your own design.

program code


int a = 37;
int b = 36;
int c = 35;
int d = 34;
int e = 33;
int f = 32;
int g = 31;
int p = 30;
int d4 = 38;
int d3 = 39;
int d2 = 40;
int d1 = 41;
long n = 0;
int m = 100;
int delay = 100;  

byte segs[7] = { a, b, c, d, e, f, g };

byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 },  // = 0
                                 { 1,0,0,1,1,1,1 },  // = 1
                                 { 0,0,1,0,0,1,0 },  // = 2
                                 { 0,0,0,0,1,1,0 },  // = 3
                                 { 1,0,0,1,1,0,0 },  // = 4
                                 { 0,1,0,0,1,0,0 },  // = 5
                                 { 0,1,0,0,0,0,0 },  // = 6
                                 { 0,0,0,1,1,1,1 },  // = 7
                                 { 0,0,0,0,0,0,0 },  // = 8
                                 { 0,0,0,0,1,0,0 }   // = 9
                             }; 

void setup()
{
  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(d4, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(p, OUTPUT);
}

void loop()
{
  clearLEDs();
  pickDigit(1);
  lightSegments((n/m/1000)%10);
  delayMicroseconds(delay);

  clearLEDs();
  pickDigit(2);
  lightSegments((n/x/100)%10);
  delayMicroseconds(del);

  clearLEDs();
  pickDigit(3);
  dispDec(3);
  lightSegments((n/x/10)%10);
  delayMicroseconds(delay);

  clearLEDs();
  pickDigit(4);
  lightSegments(n/x%10);
  delayMicroseconds(delay);

  n++;

}

void pickDigit(int x)  
{
  digitalWrite(d1, LOW);
  digitalWrite(d2, LOW);
  digitalWrite(d3, LOW);
  digitalWrite(d4, LOW);

  switch(m)
  {
  case 1: 
    digitalWrite(d1, HIGH); 
    break;
  case 2: 
    digitalWrite(d2, HIGH); 
    break;
  case 3: 
    digitalWrite(d3, HIGH); 
    break;
  default: 
    digitalWrite(d4, HIGH); 
    break;
  }
}

void dispDec(int m) 
{
  digitalWrite(p, LOW);
}

void clearLEDs()  
{
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(p, HIGH);
}
void lightSegments(int x) {
  for (int i = 0; i < 7; i++) {
    digitalWrite(segs[i], seven_seg_digits[x][i]);
  }
}

The Final vedio

Documents

4 Digital 7segment easyeda Display

BOM

ID Name Designator Footprint Quantity
1 Arduino MEGA 2560 U1 DIP 1
2 7-SEGMENT-4DIGIT LED1 4-digit-12-pin-0.28-inch 1
3 100 R1,R2,R3,R4,R5,R6,R7,R8 R3 8

Attachments

None

Members

Success
The owner does not allow comments in this project now

Comments (0)

goToTop
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.