- Ảnh mô phỏng protues.
- Đây là code chương trình.
#include <16f877a.h>
#fuses NOLVP,NOWDT,PUT,HS
#use delay(clock=20000000)
#BIT PORTCbits_RC0 = 0X07.0
#BIT PORTCbits_RC1 = 0X07.1
#BIT PORTCbits_RC3 = 0X07.3
const unsigned char font[] = {
127, 127, 14, 28, 14, 127, 127, 0, //'M'
124, 126, 19, 19, 126, 124, 0, 0, //'A'
3, 65, 127, 127, 65, 3, 0, 0, //'T'
65, 127, 127, 9, 25, 127, 102, 0, //'R'
0, 65, 127, 127, 65, 0, 0, 0, //'I'
67, 103, 60, 24, 60, 103, 67, 0, //'X'
0, 0, 0, 0, 0, 0, 0, 0, //' '
54, 127, 73, 73, 127, 54, 0, 0, //'8'
68, 108, 56, 16, 56, 108, 68, 0, //'x'
64, 66, 127, 127, 64, 64, 0, 0, //'1'
60, 126, 75, 73, 121, 48, 0, 0, //'6'
0, 0, 0, 0, 0, 0, 0, 0, //' '
0, 0, 0, 0, 0, 0, 0, 0, //' '
};
void main()
{
unsigned rol, delay, col;
SET_TRIS_B(0x00);
SET_TRIS_C(0x00);
OUTPUT_B(0x00);
OUTPUT_C(0x00);
while(1)
{
for(rol=0;rol<112;rol++)
{ //font. 13 x 8[8x8 matrix] = 112.
for(delay=0;delay<20;delay++)
{
PORTCbits_RC0 = 1; PORTCbits_RC0 = 0; PORTCbits_RC1 = 1; PORTCbits_RC3 = 1; PORTCbits_RC3 = 0;
for(col=0;col<16;col++) // 16 hang va cot
{
OUTPUT_B (~ font[col + rol]);
delay_us(300);
PORTCbits_RC0 = 1; PORTCbits_RC0 = 0; PORTCbits_RC1 = 0; PORTCbits_RC3 = 1; PORTCbits_RC3 = 0;
}
}
}
}
}
- Link download project Click here#fuses NOLVP,NOWDT,PUT,HS
#use delay(clock=20000000)
#BIT PORTCbits_RC0 = 0X07.0
#BIT PORTCbits_RC1 = 0X07.1
#BIT PORTCbits_RC3 = 0X07.3
const unsigned char font[] = {
127, 127, 14, 28, 14, 127, 127, 0, //'M'
124, 126, 19, 19, 126, 124, 0, 0, //'A'
3, 65, 127, 127, 65, 3, 0, 0, //'T'
65, 127, 127, 9, 25, 127, 102, 0, //'R'
0, 65, 127, 127, 65, 0, 0, 0, //'I'
67, 103, 60, 24, 60, 103, 67, 0, //'X'
0, 0, 0, 0, 0, 0, 0, 0, //' '
54, 127, 73, 73, 127, 54, 0, 0, //'8'
68, 108, 56, 16, 56, 108, 68, 0, //'x'
64, 66, 127, 127, 64, 64, 0, 0, //'1'
60, 126, 75, 73, 121, 48, 0, 0, //'6'
0, 0, 0, 0, 0, 0, 0, 0, //' '
0, 0, 0, 0, 0, 0, 0, 0, //' '
};
void main()
{
unsigned rol, delay, col;
SET_TRIS_B(0x00);
SET_TRIS_C(0x00);
OUTPUT_B(0x00);
OUTPUT_C(0x00);
while(1)
{
for(rol=0;rol<112;rol++)
{ //font. 13 x 8[8x8 matrix] = 112.
for(delay=0;delay<20;delay++)
{
PORTCbits_RC0 = 1; PORTCbits_RC0 = 0; PORTCbits_RC1 = 1; PORTCbits_RC3 = 1; PORTCbits_RC3 = 0;
for(col=0;col<16;col++) // 16 hang va cot
{
OUTPUT_B (~ font[col + rol]);
delay_us(300);
PORTCbits_RC0 = 1; PORTCbits_RC0 = 0; PORTCbits_RC1 = 0; PORTCbits_RC3 = 1; PORTCbits_RC3 = 0;
}
}
}
}
}
EmoticonEmoticon