មេរៀនទី១៩៖​ 7 Segment one Digit Cathode Type Using Matrix Code - Tann Thona

Telecommunication and Electronic Engineering

Post

Post Top Ad

Wednesday, December 23, 2020

មេរៀនទី១៩៖​ 7 Segment one Digit Cathode Type Using Matrix Code

7 Segment one Digit Cathode Type

 

1. Objective

The objective is talk about, Use matrix code (Array) to display 7 segment one digit cathode type.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • 7 Segment one digit x1 (Anode Type)
  • Resistor 220Ohm x1
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1. 
 
Segment Pin A to Arduino pin 13 
Segment Pin B to Arduino pin 12
Segment Pin C to Arduino pin 11 
Segment Pin D to Arduino pin 10
Segment Pin E to Arduino pin 9
Segment Pin F to Arduino pin 8
Segment Pin G to Arduino pin 7
 
*Note you must find pin A to G in real 7 segment because the pin are not order as simulation. 
 

Figure 1. Arduino Connection

4. Coding

// by Tann Thona
// 7 Segment Cathode Type

int pinA = 13;
int pinB = 12;
int pinC = 11;
int pinD = 10;
int pinE = 9;
int pinF = 8;
int pinG = 7;
int j = 0;
int i = 0;

int Arduino_Pins[7] = {pinA, pinB, pinC, pinD, pinE, pinF, pinG}; // 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
};


void setup() {
// put your setup code here, to run once:
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:

for (j = 0; j<7; j++)
{
digitalWrite(Arduino_Pins[j], Segment_Pins[i][j]);
}
delay(100);

i++;
if(i>10)
{
i = 0;
}
}

Click here to download code and simulation file

 

4. Result

According to code above,7 segment is display with count up number from 0 to 9 in loop.

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona


No comments:

Post a Comment

Post Top Ad