# 24 Digit 7-Segment Simulation+Coding

158

1

## Introduction: 24 Digit 7-Segment Simulation+Coding

Simulation of 24 x 7-segment Common Anode using proteus 8.0 , PIC16F887, MicroC for coding.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Gatherig Component

I used 3 x 8 Digit 7-Segment Common Anode to form a 24 Digit with PIC16F887 to be later programmed using MicroC.

## Step 2: Building Schematic

I connected all parts as shown in the picture with Proteus 8.0

check my video for more details

## Step 3: Coding

int tab[10]={0XC0, 0XF9, 0XA4,0XB0, 0X99, 0X92, 0X82, 0XF8, 0X80, 0X90}; //0 TO 9 HEX FORMAT

int d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24; //for each digit

int i = 0;

long int j = 0;

const delay = 20;

void main() {

TRISA = 0X00; // all ports as output

TRISB = 0X00;

TRISC = 0X00;

TRISD = 0X00;

ANSEL = 0; //configue analog pins as digital

ANSELH = 0;

C1ON_bit = 0; // disable comparator

C2ON_bit = 0;

PORTA = 0X00; //turn off all ports

PORTD = 0X00;

PORTC = 0X00;

PORTB = 0X00;

while(1){ ///////Counter on 24 digits

for (j=0; j<9999999; j++){ // j is the maximum number //remove the for loop if j overflow

i = 0; while(i<25){ // i is responsible of the amount of time each number will last PORTA = 0X01; //turn on first digit

PORTB = tab[d1];

delay_us(delay);

PORTA = 0X02;

PORTB = tab[d2];

delay_us(delay);

PORTA = 0X04;

PORTB = tab[d3];

delay_us(delay);

PORTA = 0X08;

PORTB = tab[d4];

delay_us(delay);

PORTA = 0X10;

PORTB = tab[9];

delay_us(delay);

PORTA = 0X20;

PORTB = tab[5];

delay_us(delay);

PORTA = 0X40;

PORTB = tab[1];

delay_us(delay);

PORTA = 0X80;

PORTB = tab[0];

delay_us(delay);

PORTD = 0X01;

PORTB = tab[6];

delay_us(delay);

PORTD = 0X02;

PORTB = tab[7];

delay_us(delay);

PORTD = 0X04;

PORTB = tab[8];

delay_us(delay);

PORTD = 0X08;

PORTB = tab[4];

delay_us(delay);

PORTD = 0X10;

PORTB = tab[3];

delay_us(delay);

PORTD = 0X20;

PORTB = tab[1];

delay_us(delay);

PORTD = 0X40;

PORTB = tab[4];

delay_us(delay);

PORTD = 0X80;

PORTB = tab[6];

delay_us(delay);

PORTC = 0X01;

PORTB = tab[6];

delay_us(delay);

PORTC = 0X02;

PORTB = tab[4];

delay_us(delay);

PORTC = 0X04;

PORTB = tab[3];

delay_us(delay);

PORTC = 0X08;

PORTB = tab[0];

delay_us(delay);

PORTC = 0X10;

PORTB = tab[1];

delay_us(delay);

PORTC = 0X20;

PORTB = tab[2];

delay_us(delay);

PORTC = 0X40;

PORTB = tab[8];

delay_us(delay);

PORTC = 0X80;

PORTB = tab[9];

delay_us(delay);

i++;

}

d1++;

if(d1>9){d1 = 0; d2++;}

if(d2>9){d2 = 0; d3++;}

if(d3>9){d3 = 0; d4++;}

if(d4>9){d4 = 0; d5++;}

if(d5>9){d5 = 0; d6++;}

if(d6>9){d6 = 0; d7++;}

if(d7>9){d7 = 0; d8++;}

if(d8>9){d8 = 0; d9++;}

if(d9>9){d9 = 0; d10++;}

if(d10>9){d10 = 0; d11++;}

if(d11>9){d11 = 0; d12++;}

if(d12>9){d12 = 0; d13++;}

if(d13>9){d13 = 0; d14++;}

if(d14>9){d14 = 0; d15++;}

if(d15>9){d15 = 0; d16++;}

if(d16>9){d16 = 0; d17++;}

if(d17>9){d17 = 0; d18++;}

if(d18>9){d18 = 0; d19++;}

if(d19>9){d19 = 0; d20++;}

if(d20>9){d20 = 0; d21++;}

if(d21>9){d21 = 0; d22++;}

if(d22>9){d22 = 0; d23++;}

if(d23>9){d23 = 0; d24++;}

if(d24>9){d24 = 0;}

} d1=d2=d3=d4=d5=d6=d7=d8=d9=d10=d11=d12=d13=d14=d15=d16=d17=d18=d19=d20=d21=d22=d23=d24=0; }

}

## Recommendations

110 15K
240 16K
194 23K
Large Motors Class

14,579 Enrolled