Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Code Matrix

dhhdhhyheyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjsd hhdhhyheyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjsdhhdhhyh eyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjs

Uploaded by

nhukhiemdz
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Code Matrix

dhhdhhyheyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjsd hhdhhyheyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjsdhhdhhyh eyhyxhyxhxhtxhxhnhhhhhdchdhdhhhddhhhdkjs

Uploaded by

nhukhiemdz
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Cách 1

#include <16f877a.h>
#use delay(clock=20M)
#fuses HS, NOWDT
#byte portc = 0x07
#byte portd = 0x08
#bit rc0=0x07.0
#bit rc1=0x07.1
#bit rc2=0x07.2
#define ds rc0
#define st rc1
#define sh rc2
unsigned char khung_du_lieu[32];
unsigned char socot,sohang,tocdo;
unsigned char g,h,a;

//------------------------------------------------------ du lieu cot luu vao ROM------------------------------------------


const unsigned char codedu_lieu_cot[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0x18,0x24,0x42,0x81,0x00,//k
0x00,0xff,0x18,0x18,0x18,0x18,0xff,0x00,//h
0x00,0x00,0x81,0x81,0xff,0x81,0x81,0x00,//i
0x00,0xff,0x99,0x99,0x99,0x99,0x00,0x00,//e
0x00,0xff,0x40,0x20,0x10,0x20,0x40,0xff,//m
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void tonghop(void);
void delay_ms(unsigned int ms);
void load(unsigned int u);
void main(void)
{
set_TRIS_B(0xff);
set_TRIS_D(0X00);
set_TRIS_C(0X00);
PORTD=0xff;
PORTC=0x00;
while(true)
{
tonghop();
}
}

void delay_ms(unsigned int ms)


{
unsigned int i;
unsigned char j;
for(i=0;i<ms;i++)
for(j=0;j<120;j++);
}

void load(unsigned int u)


{
unsigned char i;
for(i=0;i<32;i++)
{
khung_du_lieu[i]=codedu_lieu_cot[u];
u++;
}
}
void tonghop(void)
{
unsigned char i;
for(socot=0;socot<106;socot++) //73+32=105 la so phan tu du_lieu_cot
{
load(socot);
for(tocdo=0;tocdo<10;tocdo++)
{
a=0xfe;
h=0x80;
for(sohang=0;sohang<8;sohang++)
{
st=0;
for(i=0;i<32;i++)
{
sh=0;
g=khung_du_lieu[i];
if((g&h)==h) ds=1;
else ds=0;
sh=1;
}
st=1;
h=h>>1;
PORTD=a;
delay_ms(1);
PORTD=0xff;
a=(a<<1)+1;
}
}
}
}
Cách 2

#include <16f877a.h>
#define DATA PIN_C1 //DS
#define LATCH PIN_C3 //ST_CP
#define CLOCK PIN_C0 //SH_CP //unsigned int32
/*unsigned int32 characterHEX[][8] = {
{0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x66},//A //Gi?i mă cho led ma tr?n
{0x78,0x64,0x68,0x78,0x64,0x66,0x66,0x7C},//B
{0x3C,0x62,0x60,0x60,0x60,0x62,0x62,0x3C},//C
{0x78,0x64,0x66,0x66,0x66,0x66,0x64,0x78},//D
{0x7E,0x60,0x60,0x7C,0x60,0x60,0x60,0x7E},//E
{0x7E,0x60,0x60,0x7C,0x60,0x60,0x60,0x60},//F
{0x3C,0x62,0x60,0x60,0x66,0x62,0x62,0x3C},//G
{0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x66},//H
{0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x7E},//I
{0x7E,0x18,0x18,0x18,0x18,0x18,0x1A,0x0C},//J
{0x62,0x64,0x68,0x70,0x70,0x68,0x64,0x62},//K
{0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7E},//L
{0xC3,0xE7,0xDB,0xDB,0xC3,0xC3,0xC3,0xC3},//M
{0x62,0x62,0x52,0x52,0x4A,0x4A,0x46,0x46},//N
{0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C},//O
{0x7C,0x62,0x62,0x7C,0x60,0x60,0x60,0x60},//P
{0x38,0x64,0x64,0x64,0x64,0x6C,0x64,0x3A},//Q
{0x7C,0x62,0x62,0x7C,0x70,0x68,0x64,0x62},//R
{0x1C,0x22,0x30,0x18,0x0C,0x46,0x46,0x3C},//S
{0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18},//T
{0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C},//U
{0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x18},//V
{0x81,0x81,0x81,0x81,0x81,0x99,0x99,0x66},//W
{0x42,0x42,0x24,0x18,0x18,0x24,0x42,0x42},//X
{0xC3,0x66,0x3C,0x18,0x18,0x18,0x18,0x18},//Y
{0x7E,0x02,0x04,0x08,0x10,0x20,0x40,0x7E},//Z
};*/
int character1HEX[11][8] = {
/*
{0x18,0x38,0x58,0x18,0x18,0x18,0x18,0x7E},//1
{0x3C,0x66,0x66,0x0C,0x18,0x30,0x7E,0x7E},//2
{0x7E,0x0C,0x18,0x3C,0x06,0x06,0x46,0x3C},//3
{0x0C,0x18,0x30,0x6C,0x6C,0x7E,0x0C,0x0C},//4
{0x7E,0x60,0x60,0x7C,0x06,0x06,0x46,0x3C},//5
{0x04,0x08,0x10,0x38,0x6C,0x66,0x66,0x3C},//6
{0x7E,0x46,0x0C,0x18,0x18,0x18,0x18,0x18},//7
{0x3C,0x66,0x66,0x3C,0x66,0x66,0x66,0x3C},//8
{0x3C,0x66,0x66,0x36,0x1C,0x08,0x10,0x20},//9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},// kho?ng tr?ng
{0x00,0x66,0xFF,0xFF,0x7E,0x3C,0x18,0x00}// h?nh trái tim, kí hi?u là '&'
*/
{0x62,0x64,0x68,0x70,0x70,0x68,0x64,0x62},//K
{0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x66},//H
{0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x7E},//I
{0x7E,0x60,0x60,0x7C,0x60,0x60,0x60,0x7E},//E
{0xC3,0xE7,0xDB,0xDB,0xC3,0xC3,0xC3,0xC3},//M
};
int y[] = {0b11111110,
0b11111101,0b11111011,0b11110111,0b11101111,0b11011111,0b10111111,0b01111111};
void IC_74hc595(int8 dulieu)
{
int i;
output_low(CLOCK);
for(i=0;i<=7;i++)
{
if((dulieu & 0x80)==0)
output_low(DATA);
else
output_high(DATA);
dulieu=dulieu<<1;
output_high(CLOCK);
output_low(CLOCK);
}
}
void main()
{
set_tris_c(0x00);
set_tris_d(0x00);

while(TRUE)
{
for(int j=0;j<11;j++){
for (int i = 0; i<8 ; i++)
{
IC_74hc595(character1HEX[0][i]);//K
IC_74hc595(character1HEX[1][i]);//H
IC_74hc595(character1HEX[2][i]);//I
IC_74hc595(character1HEX[3][i]);//E
IC_74hc595(character1HEX[4][i]);//M
output_D(y[i]);
output_low(LATCH);
output_high(LATCH);

}
}

You might also like