View Full Version : Ca nha giup e voi.e dang can gap
hung06071989
14-09-2012, 10:04 AM
E DANG LAM DE TAI VE PIC 16F877A.LA HIEN THI DOAN CHU LEN LED MA TRAN.PHAN HIEN THI DOAN CHU THI E DA LAM DUOC.NHUNG THAY BAT PHAI KET NOI VOI pc DE THAY DOI DONG CHU DO KHI CAN.DUNG TRUYEN THONG RS232.NHUNG E KHONG BIET VE TRONG PROTUES THE NAO.E DUNG PHAN MEM PROTUES MO PHONG.XAI CODE TRONG CCS.MONG MOI NG GIUP E AK.VA E GUI BAI CUA E CHO MOI NGUOI XEM AK
E DANG LAM DE TAI VE PIC 16F877A.LA HIEN THI DOAN CHU LEN LED MA TRAN.PHAN HIEN THI DOAN CHU THI E DA LAM DUOC.NHUNG THAY BAT PHAI KET NOI VOI pc DE THAY DOI DONG CHU DO KHI CAN.DUNG TRUYEN THONG RS232.NHUNG E KHONG BIET VE TRONG PROTUES THE NAO.E DUNG PHAN MEM PROTUES MO PHONG.XAI CODE TRONG CCS.MONG MOI NG GIUP E AK.VA E GUI BAI CUA E CHO MOI NGUOI XEM AK
tham khảo tại đây:http://www.picvietnam.com/forum/showthread.php?t=9261
hung06071989
17-09-2012, 10:22 PM
a oi.e da xem bai cua e gui cho e.e copy ve.va sua lai.va lam theo nhung gi a huong dan.nhung no khong chay.a giup rui giup lai gium e nha
hung06071989
19-09-2012, 07:31 PM
giup e voi a oi
giup e voi a oi
////////////////////////////////////////////////////////////////////////////////
//----------------------TKHM MON HOC HE THONG NHUNG--------------------------//
//----------------------------LED MATRIX 8X32---------------------------------//
// Phan cung: PIC 16F877A - Thach anh 20Mhz //
// IC chot dich 74HC595 - Quet cot //
// Ngay thuc hien: 15/09/2012 //
// Ngay hoan thanh: 28/09/2012 //
////////////////////////////////////////////////////////////////////////////////
#include <16f877a.h>
#device 16f877a*=16 ADC=10
#include <stdlib.h>
#include <string.h>
#fuses nowdt,noprotect,nolvp,hs,put
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use rs232(baud=9600,parity=N,xmit=pin_c6,rcv=pin_c7)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit b0=portb.0
#bit b1=portb.1
#bit b2=portb.2
#bit b3=portb.3
#bit b4=portb.4
#bit b5=portb.5
int dich_chu=0,toc_doc_chay=0;
void lay_font(char * textptr);
unsigned char bi,temp,chieu_dai=0;
unsigned char hien_thi[96];
char string1[18]={"tdm_012635587xx"};//thay đổi chu hien thi tai day
const BYTE TEXT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x5F, 0x00, 0x00, // !
0x00, 0x03, 0x00, 0x03, 0x00, // "
0x14, 0x3E, 0x14, 0x3E, 0x14, // #
0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
0x43, 0x33, 0x08, 0x66, 0x61, // %
0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x1C, 0x22, 0x41, 0x00, // (
0x00, 0x41, 0x22, 0x1C, 0x00, // )
0x14, 0x08, 0x3E, 0x08, 0x14, // *
0x08, 0x08, 0x3E, 0x08, 0x08, // +
0x00, 0x50, 0x30, 0x00, 0x00, // ,
0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x60, 0x60, 0x00, 0x00, // .
0x20, 0x10, 0x08, 0x04, 0x02, // /
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x04, 0x02, 0x7F, 0x00, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x22, 0x41, 0x49, 0x49, 0x36, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3E, 0x49, 0x49, 0x49, 0x32, // 6
0x01, 0x01, 0x71, 0x09, 0x07, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x26, 0x49, 0x49, 0x49, 0x3E, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x08, 0x14, 0x22, 0x41, 0x00, // <
0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x41, 0x22, 0x14, 0x08, // >
0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x3E, 0x41, 0x59, 0x55, 0x5E, // @
0x7E, 0x09, 0x09, 0x09, 0x7E, // A
0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x7F, 0x41, 0x41, 0x41, 0x3E, // D
0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x7F, 0x09, 0x09, 0x09, 0x01, // F
0x3E, 0x41, 0x41, 0x49, 0x3A, // G
0x7F, 0x08, 0x08, 0x08, 0x7F, // H
0x00, 0x41, 0x7F, 0x41, 0x00, // I
0x30, 0x40, 0x40, 0x40, 0x3F, // J
0x7F, 0x08, 0x14, 0x22, 0x41, // K
0x7F, 0x40, 0x40, 0x40, 0x40, // L
0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
0x7F, 0x02, 0x04, 0x08, 0x7F, // N
0x3E, 0x41, 0x41, 0x41, 0x3E, // O
0x7F, 0x09, 0x09, 0x09, 0x06, // P
0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
0x7F, 0x09, 0x09, 0x09, 0x76};// R
const BYTE TEXT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
0x01, 0x01, 0x7F, 0x01, 0x01, // T
0x3F, 0x40, 0x40, 0x40, 0x3F, // U
0x1F, 0x20, 0x40, 0x20, 0x1F, // V
0x7F, 0x20, 0x10, 0x20, 0x7F, // W
0x41, 0x22, 0x1C, 0x22, 0x41, // X
0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x7F, 0x41, 0x00, 0x00, // [
0x02, 0x04, 0x08, 0x10, 0x20, // \
0x00, 0x00, 0x41, 0x7F, 0x00, // ]
0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x01, 0x02, 0x04, 0x00, // `
0x20, 0x54, 0x54, 0x54, 0x78, // a
0x7F, 0x44, 0x44, 0x44, 0x38, // b
0x38, 0x44, 0x44, 0x44, 0x44, // c
0x38, 0x44, 0x44, 0x44, 0x7F, // d
0x38, 0x54, 0x54, 0x54, 0x18, // e
0x04, 0x04, 0x7E, 0x05, 0x05, // f
0x08, 0x54, 0x54, 0x54, 0x3C, // g
0x7F, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x44, 0x7D, 0x40, 0x00, // i
0x20, 0x40, 0x44, 0x3D, 0x00, // j
0x7F, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x41, 0x7F, 0x40, 0x00, // l
0x7C, 0x04, 0x78, 0x04, 0x78, // m
0x7C, 0x08, 0x04, 0x04, 0x78, // n
0x38, 0x44, 0x44, 0x44, 0x38, // o
0x7C, 0x14, 0x14, 0x14, 0x08, // p
0x08, 0x14, 0x14, 0x14, 0x7C, // q
0x00, 0x7C, 0x08, 0x04, 0x04, // r
0x48, 0x54, 0x54, 0x54, 0x20, // s
0x04, 0x04, 0x3F, 0x44, 0x44, // t
0x3C, 0x40, 0x40, 0x20, 0x7C, // u
0x1C, 0x20, 0x40, 0x20, 0x1C, // v
0x3C, 0x40, 0x30, 0x40, 0x3C, // w
0x44, 0x28, 0x10, 0x28, 0x44, // x
0x0C, 0x50, 0x50, 0x50, 0x3C, // y
0x44, 0x64, 0x54, 0x4C, 0x44, // z
0x00, 0x08, 0x36, 0x41, 0x41, // {
0x00, 0x00, 0x7F, 0x00, 0x00, // |
0x41, 0x41, 0x36, 0x08, 0x00, // }
0x02, 0x01, 0x02, 0x04, 0x02};// ~
int8 i,m,t,flag,dem;
int8 n;
char mang[];
void dich(void);
void xuat(unsigned char bi);
void xoa_hien_thi();
#INT_RDA
void ngat()
{
mang[dem]=getc();
if(mang[dem]=='#')
{
flag=1;//co ngat
dem=0;
}
else{
dem++;
}
}
void main()
{int x=0;
enable_interrupts(INT_RDA);
enable_interrupts(global);
set_tris_b(0b00000000);
int dich_chu=0,toc_do_chay=0;
while(1)
{
xoa_hien_thi();//xóa vùng nho hien thi truoc
lay_font(string1); // Write character set to matrix
for(dich_chu=0;dich_chu<=63;dich_chu++)
{
for(toc_do_chay=0;toc_do_chay<=2;toc_do_chay++)
{
b1=1;
b0=1;
b2=1;
b0=0;
b2=0;
for(m=0;m<=32;m++)
{
n=hien_thi[m+dich_chu];
n=~n;
xuat(n);
delay_us(1000);
dich();
}
}
}
}
}
void dich()
{
b1=0;
b0=1;
b0=0;
b2=1;
b2=0;
}
void xuat(unsigned char temp)
{
#bit flag_bit = temp.7
b4=0;
for(i=0;i<=7;i++)
{
if(flag_bit==1)
{b4=1;}
else
{b4=0;}
b3=1;
b3=0;
temp<<=1;
}
b5=1;
b5=0;
}
void lay_font(char * textptr)
{
int i, j;//
BYTE pixelData[5]; // Stores character data
for(i=0; textptr[i] != '\0'; ++i ) // Loop through the passed string
{
if(textptr[i] == '#')//textptr khai bao vi tri con tro
break;
if(textptr[i] < 'S') //ky tu nam o mang text
memcpy(pixelData, TEXT[textptr[i]-' '], 5);//copy 5 byte gia tri text[textptr[i]-'' vao pixeldata
else if(textptr[i] <= '~') // ky tu nam o mang text2
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);//copy 5 byte gia tri text2[textptr[i]-'s' vao pixeldata
else
memcpy(pixelData, TEXT[0], 5); // khoang trang
for(j=0;j<=4;j++)
{
hien_thi[chieu_dai]=(pixelData[j]);//hien thi tung ky tu
chieu_dai++;
}
}
}
void xoa_hien_thi(void)
{
chieu_dai=0;
for(m=0;m<=96;m++)
{
hien_thi[m]=0x00;
}
}
em hiểu ct viết ở trên như thế nào ,để anh biết còn hướng dẫn.
hung06071989
20-09-2012, 10:16 AM
theo e hieu thi chuong trinh cua a la nhap chuoi ky tu.rui chuoi ky tu nay duoc truyen qua pic va pic so sanh voi cac ky tu trong mang char va hien thi ra led ma tran dung ko a.do e moi hoc mon nay.voi lai hoc mon he thong nhung nay ga lam.co gi a chi bao cho e ak.t7 nay e nop rui.xin a giup gium e ak.cam on a rat nhieu ak
theo e hieu thi chuong trinh cua a la nhap chuoi ky tu.rui chuoi ky tu nay duoc truyen qua pic va pic so sanh voi cac ky tu trong mang char va hien thi ra led ma tran dung ko a.do e moi hoc mon nay.voi lai hoc mon he thong nhung nay ga lam.co gi a chi bao cho e ak.t7 nay e nop rui.xin a giup gium e ak.cam on a rat nhieu ak
dùng phần mềm com ảo để kết nối với proteus.
thay thạch anh trong proteus bằng 20mhz.
////////////////////////////////////////////////////////////////////////////////
//----------------------TKHM MON HOC HE THONG NHUNG--------------------------//
//----------------------------LED MATRIX 8X32---------------------------------//
// Phan cung: PIC 16F877A - Thach anh 20Mhz //
// IC chot dich 74HC595 - Quet cot //
// Ngay thuc hien: 15/09/2012 //
// Ngay hoan thanh: 28/09/2012 //
////////////////////////////////////////////////////////////////////////////////
#include <16f877a.h>
#device 16f877a*=16 ADC=10
#include <stdlib.h>
#include <string.h>
#fuses nowdt,noprotect,nolvp,hs,put
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use rs232(baud=9600,parity=N,xmit=pin_c6,rcv=pin_c7)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit b0=portb.0
#bit b1=portb.1
#bit b2=portb.2
#bit b3=portb.3
#bit b4=portb.4
#bit b5=portb.5
int dich_chu=0,toc_doc_chay=0;
void lay_font(char * textptr);
unsigned char bi,temp,chieu_dai=0;
unsigned char hien_thi[96];
char string1[18]={"tdm_012635587xx"};//thay doi chu hien thi tai day
const BYTE TEXT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x5F, 0x00, 0x00, // !
0x00, 0x03, 0x00, 0x03, 0x00, // "
0x14, 0x3E, 0x14, 0x3E, 0x14, // #
0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
0x43, 0x33, 0x08, 0x66, 0x61, // %
0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x1C, 0x22, 0x41, 0x00, // (
0x00, 0x41, 0x22, 0x1C, 0x00, // )
0x14, 0x08, 0x3E, 0x08, 0x14, // *
0x08, 0x08, 0x3E, 0x08, 0x08, // +
0x00, 0x50, 0x30, 0x00, 0x00, // ,
0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x60, 0x60, 0x00, 0x00, // .
0x20, 0x10, 0x08, 0x04, 0x02, // /
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x04, 0x02, 0x7F, 0x00, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x22, 0x41, 0x49, 0x49, 0x36, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3E, 0x49, 0x49, 0x49, 0x32, // 6
0x01, 0x01, 0x71, 0x09, 0x07, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x26, 0x49, 0x49, 0x49, 0x3E, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x08, 0x14, 0x22, 0x41, 0x00, // <
0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x41, 0x22, 0x14, 0x08, // >
0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x3E, 0x41, 0x59, 0x55, 0x5E, // @
0x7E, 0x09, 0x09, 0x09, 0x7E, // A
0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x7F, 0x41, 0x41, 0x41, 0x3E, // D
0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x7F, 0x09, 0x09, 0x09, 0x01, // F
0x3E, 0x41, 0x41, 0x49, 0x3A, // G
0x7F, 0x08, 0x08, 0x08, 0x7F, // H
0x00, 0x41, 0x7F, 0x41, 0x00, // I
0x30, 0x40, 0x40, 0x40, 0x3F, // J
0x7F, 0x08, 0x14, 0x22, 0x41, // K
0x7F, 0x40, 0x40, 0x40, 0x40, // L
0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
0x7F, 0x02, 0x04, 0x08, 0x7F, // N
0x3E, 0x41, 0x41, 0x41, 0x3E, // O
0x7F, 0x09, 0x09, 0x09, 0x06, // P
0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
0x7F, 0x09, 0x09, 0x09, 0x76};// R
const BYTE TEXT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
0x01, 0x01, 0x7F, 0x01, 0x01, // T
0x3F, 0x40, 0x40, 0x40, 0x3F, // U
0x1F, 0x20, 0x40, 0x20, 0x1F, // V
0x7F, 0x20, 0x10, 0x20, 0x7F, // W
0x41, 0x22, 0x1C, 0x22, 0x41, // X
0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x7F, 0x41, 0x00, 0x00, // [
0x02, 0x04, 0x08, 0x10, 0x20, // \
0x00, 0x00, 0x41, 0x7F, 0x00, // ]
0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x01, 0x02, 0x04, 0x00, // `
0x20, 0x54, 0x54, 0x54, 0x78, // a
0x7F, 0x44, 0x44, 0x44, 0x38, // b
0x38, 0x44, 0x44, 0x44, 0x44, // c
0x38, 0x44, 0x44, 0x44, 0x7F, // d
0x38, 0x54, 0x54, 0x54, 0x18, // e
0x04, 0x04, 0x7E, 0x05, 0x05, // f
0x08, 0x54, 0x54, 0x54, 0x3C, // g
0x7F, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x44, 0x7D, 0x40, 0x00, // i
0x20, 0x40, 0x44, 0x3D, 0x00, // j
0x7F, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x41, 0x7F, 0x40, 0x00, // l
0x7C, 0x04, 0x78, 0x04, 0x78, // m
0x7C, 0x08, 0x04, 0x04, 0x78, // n
0x38, 0x44, 0x44, 0x44, 0x38, // o
0x7C, 0x14, 0x14, 0x14, 0x08, // p
0x08, 0x14, 0x14, 0x14, 0x7C, // q
0x00, 0x7C, 0x08, 0x04, 0x04, // r
0x48, 0x54, 0x54, 0x54, 0x20, // s
0x04, 0x04, 0x3F, 0x44, 0x44, // t
0x3C, 0x40, 0x40, 0x20, 0x7C, // u
0x1C, 0x20, 0x40, 0x20, 0x1C, // v
0x3C, 0x40, 0x30, 0x40, 0x3C, // w
0x44, 0x28, 0x10, 0x28, 0x44, // x
0x0C, 0x50, 0x50, 0x50, 0x3C, // y
0x44, 0x64, 0x54, 0x4C, 0x44, // z
0x00, 0x08, 0x36, 0x41, 0x41, // {
0x00, 0x00, 0x7F, 0x00, 0x00, // |
0x41, 0x41, 0x36, 0x08, 0x00, // }
0x02, 0x01, 0x02, 0x04, 0x02};// ~
int8 i,m,t,flag,dem;
int8 n;
char mang[];
void dich(void);
void xuat(unsigned char bi);
void xoa_hien_thi();
#INT_RDA
void ngat()
{
string1[dem]=getc();
if(string1[dem]=='#')//ki tu ket thuc truyen
{
dem=0;
}
else{
dem++;
}
}
void main()
{int x=0;
enable_interrupts(INT_RDA);
enable_interrupts(global);
set_tris_b(0b00000000);
int dich_chu=0,toc_do_chay=0;
dem=0;
while(1)
{
xoa_hien_thi();//xóa vùng nho hien thi truoc
lay_font(string1); // Write character set to matrix
for(dich_chu=0;dich_chu<=63;dich_chu++)
{
for(toc_do_chay=0;toc_do_chay<=2;toc_do_chay++)
{
b1=1;
b0=1;
b2=1;
b0=0;
b2=0;
for(m=0;m<=32;m++)
{
n=hien_thi[m+dich_chu];
n=~n;
xuat(n);
delay_us(1000);
dich();
}
}
}
}
}
void dich()
{
b1=0;
b0=1;
b0=0;
b2=1;
b2=0;
}
void xuat(unsigned char temp)
{
#bit flag_bit = temp.7
b4=0;
for(i=0;i<=7;i++)
{
if(flag_bit==1)
{b4=1;}
else
{b4=0;}
b3=1;
b3=0;
temp<<=1;
}
b5=1;
b5=0;
}
void lay_font(char * textptr)
{
int i, j;//
BYTE pixelData[5]; // Stores character data
for(i=0; textptr[i] != '\0'; ++i ) // Loop through the passed string
{
if(textptr[i] == '#')//textptr khai bao vi tri con tro
break;
if(textptr[i] < 'S') //ky tu nam o mang text
memcpy(pixelData, TEXT[textptr[i]-' '], 5);//copy 5 byte gia tri text[textptr[i]-'' vao pixeldata
else if(textptr[i] <= '~') // ky tu nam o mang text2
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);//copy 5 byte gia tri text2[textptr[i]-'s' vao pixeldata
else
memcpy(pixelData, TEXT[0], 5); // khoang trang
for(j=0;j<=4;j++)
{
hien_thi[chieu_dai]=(pixelData[j]);//hien thi tung ky tu
chieu_dai++;
}
}
}
void xoa_hien_thi(void)
{
chieu_dai=0;
for(m=0;m<=96;m++)
{
hien_thi[m]=0x00;
}
}
hung06071989
21-09-2012, 11:11 AM
dùng phần mềm com ảo để kết nối với proteus.
thay thạch anh trong proteus bằng 20mhz.
////////////////////////////////////////////////////////////////////////////////
//----------------------TKHM MON HOC HE THONG NHUNG--------------------------//
//----------------------------LED MATRIX 8X32---------------------------------//
// Phan cung: PIC 16F877A - Thach anh 20Mhz //
// IC chot dich 74HC595 - Quet cot //
// Ngay thuc hien: 15/09/2012 //
// Ngay hoan thanh: 28/09/2012 //
////////////////////////////////////////////////////////////////////////////////
#include <16f877a.h>
#device 16f877a*=16 ADC=10
#include <stdlib.h>//day la thu vien gi vay a?chua nang cua no la gi?
#include <string.h>
#fuses nowdt,noprotect,nolvp,hs,put
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use rs232(baud=9600,parity=N,xmit=pin_c6,rcv=pin_c7)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit b0=portb.0
#bit b1=portb.1
#bit b2=portb.2
#bit b3=portb.3
#bit b4=portb.4
#bit b5=portb.5
int dich_chu=0,toc_doc_chay=0;
void lay_font(char * textptr);//day la gi vay a?
unsigned char bi,temp,chieu_dai=0;
unsigned char hien_thi[96];//tai sao day la so 96?thay doi so khac dc ko a?
char string1[18]={"tdm_012635587xx"};//thay doi chu hien thi tai day
const BYTE TEXT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x5F, 0x00, 0x00, // !
0x00, 0x03, 0x00, 0x03, 0x00, // "
0x14, 0x3E, 0x14, 0x3E, 0x14, // #
0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
0x43, 0x33, 0x08, 0x66, 0x61, // %
0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x1C, 0x22, 0x41, 0x00, // (
0x00, 0x41, 0x22, 0x1C, 0x00, // )
0x14, 0x08, 0x3E, 0x08, 0x14, // *
0x08, 0x08, 0x3E, 0x08, 0x08, // +
0x00, 0x50, 0x30, 0x00, 0x00, // ,
0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x60, 0x60, 0x00, 0x00, // .
0x20, 0x10, 0x08, 0x04, 0x02, // /
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x04, 0x02, 0x7F, 0x00, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x22, 0x41, 0x49, 0x49, 0x36, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3E, 0x49, 0x49, 0x49, 0x32, // 6
0x01, 0x01, 0x71, 0x09, 0x07, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x26, 0x49, 0x49, 0x49, 0x3E, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x08, 0x14, 0x22, 0x41, 0x00, // <
0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x41, 0x22, 0x14, 0x08, // >
0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x3E, 0x41, 0x59, 0x55, 0x5E, // @
0x7E, 0x09, 0x09, 0x09, 0x7E, // A
0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x7F, 0x41, 0x41, 0x41, 0x3E, // D
0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x7F, 0x09, 0x09, 0x09, 0x01, // F
0x3E, 0x41, 0x41, 0x49, 0x3A, // G
0x7F, 0x08, 0x08, 0x08, 0x7F, // H
0x00, 0x41, 0x7F, 0x41, 0x00, // I
0x30, 0x40, 0x40, 0x40, 0x3F, // J
0x7F, 0x08, 0x14, 0x22, 0x41, // K
0x7F, 0x40, 0x40, 0x40, 0x40, // L
0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
0x7F, 0x02, 0x04, 0x08, 0x7F, // N
0x3E, 0x41, 0x41, 0x41, 0x3E, // O
0x7F, 0x09, 0x09, 0x09, 0x06, // P
0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
0x7F, 0x09, 0x09, 0x09, 0x76};// R
const BYTE TEXT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
0x01, 0x01, 0x7F, 0x01, 0x01, // T
0x3F, 0x40, 0x40, 0x40, 0x3F, // U
0x1F, 0x20, 0x40, 0x20, 0x1F, // V
0x7F, 0x20, 0x10, 0x20, 0x7F, // W
0x41, 0x22, 0x1C, 0x22, 0x41, // X
0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x7F, 0x41, 0x00, 0x00, // [
0x02, 0x04, 0x08, 0x10, 0x20, // \
0x00, 0x00, 0x41, 0x7F, 0x00, // ]
0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x01, 0x02, 0x04, 0x00, // `
0x20, 0x54, 0x54, 0x54, 0x78, // a
0x7F, 0x44, 0x44, 0x44, 0x38, // b
0x38, 0x44, 0x44, 0x44, 0x44, // c
0x38, 0x44, 0x44, 0x44, 0x7F, // d
0x38, 0x54, 0x54, 0x54, 0x18, // e
0x04, 0x04, 0x7E, 0x05, 0x05, // f
0x08, 0x54, 0x54, 0x54, 0x3C, // g
0x7F, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x44, 0x7D, 0x40, 0x00, // i
0x20, 0x40, 0x44, 0x3D, 0x00, // j
0x7F, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x41, 0x7F, 0x40, 0x00, // l
0x7C, 0x04, 0x78, 0x04, 0x78, // m
0x7C, 0x08, 0x04, 0x04, 0x78, // n
0x38, 0x44, 0x44, 0x44, 0x38, // o
0x7C, 0x14, 0x14, 0x14, 0x08, // p
0x08, 0x14, 0x14, 0x14, 0x7C, // q
0x00, 0x7C, 0x08, 0x04, 0x04, // r
0x48, 0x54, 0x54, 0x54, 0x20, // s
0x04, 0x04, 0x3F, 0x44, 0x44, // t
0x3C, 0x40, 0x40, 0x20, 0x7C, // u
0x1C, 0x20, 0x40, 0x20, 0x1C, // v
0x3C, 0x40, 0x30, 0x40, 0x3C, // w
0x44, 0x28, 0x10, 0x28, 0x44, // x
0x0C, 0x50, 0x50, 0x50, 0x3C, // y
0x44, 0x64, 0x54, 0x4C, 0x44, // z
0x00, 0x08, 0x36, 0x41, 0x41, // {
0x00, 0x00, 0x7F, 0x00, 0x00, // |
0x41, 0x41, 0x36, 0x08, 0x00, // }
0x02, 0x01, 0x02, 0x04, 0x02};// ~
int8 i,m,t,flag,dem;
int8 n;
char mang[];
void dich(void);
void xuat(unsigned char bi);//bi la cai gi vay a?
void xoa_hien_thi();
#INT_RDA
void ngat()
{
string1[dem]=getc();
if(string1[dem]=='#')//ki tu ket thuc truyen
{
dem=0;
}
else{
dem++;
}
}
void main()
{int x=0;
enable_interrupts(INT_RDA);
enable_interrupts(global);
set_tris_b(0b00000000);
int dich_chu=0,toc_do_chay=0;
dem=0;
while(1)
{
xoa_hien_thi();//xóa vùng nho hien thi truoc
lay_font(string1); // Write character set to matrix
for(dich_chu=0;dich_chu<=63;dich_chu++)
{
for(toc_do_chay=0;toc_do_chay<=2;toc_do_chay++)
{
b1=1;
b0=1;
b2=1;
b0=0;
b2=0;
for(m=0;m<=32;m++)
{
n=hien_thi[m+dich_chu];
n=~n;
xuat(n);
delay_us(1000);
dich();
}
}
}
}
}
void dich()
{
b1=0;
b0=1;
b0=0;
b2=1;
b2=0;
}
void xuat(unsigned char temp)
{
#bit flag_bit = temp.7//day la cai gi vay a?
b4=0;
for(i=0;i<=7;i++)
{
if(flag_bit==1)
{b4=1;}
else
{b4=0;}
b3=1;
b3=0;
temp<<=1;
}
b5=1;
b5=0;
}
void lay_font(char * textptr)
{
int i, j;//
BYTE pixelData[5]; // Stores character data
for(i=0; textptr[i] != '\0'; ++i ) // Loop through the passed string
{
if(textptr[i] == '#')//textptr khai bao vi tri con tro
break;
if(textptr[i] < 'S') //ky tu nam o mang text
memcpy(pixelData, TEXT[textptr[i]-' '], 5);//copy 5 byte gia tri text[textptr[i]-'' vao pixeldata
else if(textptr[i] <= '~') // ky tu nam o mang text2
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);//copy 5 byte gia tri text2[textptr[i]-'s' vao pixeldata
else
memcpy(pixelData, TEXT[0], 5); // khoang trang
for(j=0;j<=4;j++)
{
hien_thi[chieu_dai]=(pixelData[j]);//hien thi tung ky tu
chieu_dai++;
}
}
}
void xoa_hien_thi(void)
{
chieu_dai=0;
for(m=0;m<=96;m++)
{
hien_thi[m]=0x00;
}
}
a giai thich gium e may lech nha a,ko e nop bai thay hoi la e died mat.voi lai a oi.sao bai cua minh no ko hien thui dc dong chu dai ak a.voi lai no hay bi mat chu lam a oi.sao ko cho no chay tu dau dong ky tu den het a.lam phien a wa.e cam on a rat nhieu ak
a giai thich gium e may lech nha a,ko e nop bai thay hoi la e died mat.voi lai a oi.sao bai cua minh no ko hien thui dc dong chu dai ak a.voi lai no hay bi mat chu lam a oi.sao ko cho no chay tu dau dong ky tu den het a.lam phien a wa.e cam on a rat nhieu ak
#include <stdlib.h> dòng này dư bỏ đi đỡ phải giải thích với ông thầy.
ram không đủ nên chỉ được 19 ki tự.
không có chuyện mất chữ.
hung06071989
22-09-2012, 09:42 PM
unsigned char hien_thi[96];//tai sao day la so 96?thay doi so khac dc ko a?
unsigned char hien_thi[96];//tai sao day la so 96?thay doi so khac dc ko a?
em online bằng gì mà không viết chữ có dấu.
với dòng pic 16 ccsc chỉ cho khai báo mảng tối đa là 96 byte.
em có thể thay đổi số khác nhung nhỏ hơn 96.
nếu muốn hiển thị nhiều hơn dùng dòng pic 18 .
hung06071989
23-09-2012, 04:15 PM
e cám ơn a ak
nhiot081290
08-11-2012, 12:55 AM
mặc dù đọc hiểu ý của bạn nhưng bạn post bài thì nên chú ý đến cảm nhận của người đọc.
bạn viết không dấu thế này không ổn rồi.
có chắng nên suy nghĩ lại....
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.