Sayfalar

Menü

2 Ağustos 2021 Pazartesi

Keypad ile sevensegment tarama yontemi ccs compiler

Keypad ile sevensegment tarama yontemi ccs compiler

 #include<16f877a.h>

#use delay (clock=4m)
#fuses brownout,hs,nowdt,nolvp

#define col1 pin_d4
#define col2 pin_d5
#define col3 pin_d6
#define col4 pin_d7

#define row1 pin_d0
#define row2 pin_d1
#define row3 pin_d2
#define row4 pin_d3

void kp_scan (void);

void main()
{
output_c(0x00);
while(true)
{
kp_scan();
delay_ms(200);
}
}

void kp_scan(void)
{
output_high(row1);
output_high(row2);
output_high(row3);
output_high(row4);

output_low (row1);
if(input(col1)==0) output_c(0b00000111); //7

output_high (row1); output_low (row2);
if(input(col1)==0) output_c(0b01100110); //4

output_high (row2); output_low (row3);
if(input(col1)==0) output_c(0b00000110); //1

output_high (row3); output_low (row4);
if(input(col1)==0) output_c(0b00111001); //c

////////////////

output_high (row4); output_low (row1);
if(input(col2)==0) output_c(0b01111111); //8

output_high (row1); output_low (row2);
if(input(col2)==0) output_c(0b01101101); //5

output_high (row2); output_low (row3);
if(input(col2)==0) output_c(0b01011011); //2

output_high (row3); output_low (row4);
if(input(col2)==0) output_c(0b00111111); //0

////////////

output_high (row4); output_low (row1);
if(input(col3)==0) output_c(0b01101111); //9

output_high (row1); output_low (row2);
if(input(col3)==0) output_c(0b01111101); //6

output_high (row2); output_low (row3);
if(input(col3)==0) output_c(0b01001111); //3

output_high (row3); output_low (row4);
if(input(col3)==0) output_c(0b11110001); //f

//////////

output_high (row4); output_low (row1);
if(input(col4)==0) output_c(0b01110111); //a

output_high (row1); output_low (row2);
if(input(col4)==0) output_c(0b01111100); //b

output_high (row2); output_low (row3);
if(input(col4)==0) output_c(0b00111001); //c

output_high (row3); output_low (row4);
if(input(col4)==0) output_c(0b01011110); //d

}


Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...