មេរៀនទី១៨៖ 7 Segment one Digit Anode Type (Simple Code) - Tann Thona

Telecommunication and Electronic Engineering

Post

Post Top Ad

Tuesday, December 22, 2020

មេរៀនទី១៨៖ 7 Segment one Digit Anode Type (Simple Code)

7 Segment one Digit Anode Type

 

1. Objective

The objective is talk about, Use digital output to display 7 segment one digit anode 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 Anode Type

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

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:

// Number 0
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 1);
delay(100);

// Number 1
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 2
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 1);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 1);
digitalWrite(pinG, 0);
delay(100);

// Number 3
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 0);
delay(100);

// Number 4
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 5
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 6
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 7
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 8
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 9
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);
}

 Click Here to Download Code and Proteus Simulation

 

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