cho em hỏi cái code của em sao nap vào nó không chạy vậy em cắm 2 công p1 và p3
em cám ơn trước
#include "AT89C51.h"
//--------------------------------------------------------------------
bdata unsigned char tmp;
sbit bit0 = tmp^0;
sbit bit1 = tmp^1;
sbit bit2 = tmp^2;
sbit bit3 = tmp^3;
sbit bit4 = tmp^4;
bit time0;
unsigned char dong[52][5];
unsigned char bangma[130] = {
0x3F,0x50,0x90,0x50,0x3F,//A
0xFF,0x99,0x99,0x66,0x00,//B
0x7E,0x81,0x81,0x81,0x42,//C
0xFF,0x81,0x81,0x42,0x3C,//D
0xFF,0x91,0x91,0x91,0x81,//E
0xFF,0x90,0x90,0x90,0x80,//F
0x7E,0x81,0x89,0x4F,0x08,//G
0xFF,0x10,0x10,0x10,0xFF,//H
0x81,0x81,0xFF,0x81,0x81,//I
0x87,0x81,0xFF,0x80,0x80,//J
0xFF,0x28,0x44,0x82,0x01,//K
0xFF,0x01,0x01,0x01,0x01,//L
0xFF,0x40,0x20,0x40,0xFF,//M
0xFF,0x20,0x08,0x02,0xFF,//N
0x7E,0x81,0x81,0x81,0x7E,//O
0xFF,0x88,0x88,0x88,0x70,//P
0x7E,0x81,0x85,0x7E,0x01,//Q
0xFF,0x98,0x94,0x62,0x01,//R
0x62,0x91,0x91,0x91,0x4E,//S
0x80,0x80,0xFF,0x80,0x80,//T
0xFE,0x01,0x01,0x01,0xFE,//U
0xF0,0x04,0x01,0x04,0xF0,//V
0xFE,0x01,0x0E,0x01,0xFE,//W
0xC3,0x24,0x18,0x24,0xC3,//X
0x80,0x40,0x3F,0x40,0x80,//Y
0x87,0x89,0x91,0xA1,0xC1//Z
};
unsigned char title[50] = "Chuc mung nam moi";
//------------------------------------------------------------------------------------------------
void Timer0_ISR(void) interrupt 1
{
EA = 0;
ET0 = 0;
IE0 = 0;
time0 = 0;
TR0=0; //stop time0
TF0=0;
return;
}
void delay(unsigned char n) /* do nothing n*1ms */
{
unsigned char j;
j=n;
do
{ EA = 1;
ET0 = 1;
IE0 = 1;
TL0=(65535-921)&0xff; // set time0 = 1ms
TH0=(65535-921)>>8;
TR0=1; // start time0
time0 = 1;
while (time0){}
}
while (--j!=0);
}
void trabang(unsigned char vitri,m)
{
unsigned char v,n,l;
v = vitri;
l = m;
for (n=0;n<5;n++)
dong[l][n] = bangma[v+n];
}
void dongchuchay(void)
{
unsigned char m;
for (m = 0; m < 50; m++)
{
switch (title[m])
{
case ('A'): trabang(0,m); break;
case ('a'): trabang(0,m); break;
case ('B'): trabang(5,m); break;
case ('b'): trabang(5,m); break;
case ('C'): trabang(10,m); break;
case ('c'): trabang(10,m); break;
case ('D'): trabang(15,m); break;
case ('d'): trabang(15,m); break;
case ('E'): trabang(20,m); break;
case ('e'): trabang(20,m); break;
case ('F'): trabang(25,m); break;
case ('f'): trabang(25,m); break;
case ('G'): trabang(30,m); break;
case ('g'): trabang(30,m); break;
case ('H'): trabang(35,m); break;
case ('h'): trabang(35,m); break;
case ('I'): trabang(40,m); break;
case ('i'): trabang(40,m); break;
case ('J'): trabang(45,m); break;
case ('j'): trabang(45,m); break;
case ('K'): trabang(50,m); break;
case ('k'): trabang(50,m); break;
case ('L'): trabang(55,m); break;
case ('l'): trabang(55,m); break;
case ('M'): trabang(60,m); break;
case ('m'): trabang(60,m); break;
case ('N'): trabang(65,m); break;
case ('n'): trabang(65,m); break;
case ('O'): trabang(70,m); break;
case ('o'): trabang(70,m); break;
case ('P'): trabang(75,m); break;
case ('p'): trabang(75,m); break;
case ('Q'): trabang(80,m); break;
case ('q'): trabang(80,m); break;
case ('R'): trabang(85,m); break;
case ('r'): trabang(85,m); break;
case ('S'): trabang(90,m); break;
case ('s'): trabang(90,m); break;
case ('T'): trabang(95,m); break;
case ('t'): trabang(95,m); break;
case ('U'): trabang(100,m); break;
case ('u'): trabang(100,m); break;
case ('V'): trabang(105,m); break;
case ('v'): trabang(105,m); break;
case ('W'): trabang(110,m); break;
case ('w'): trabang(110,m); break;
case ('X'): trabang(115,m); break;
case ('x'): trabang(115,m); break;
case ('Y'): trabang(120,m); break;
case ('y'): trabang(120,m); break;
case ('Z'): trabang(125,m); break;
case ('z'): trabang(125,m); break;
}
}
}
//--------------------------------------------------------------------
void hiencot(unsigned char ma, unsigned char cot)
{
tmp = cot;//+1;
P1 = 0x00;
P3_0 = bit0;
P3_1 = bit1;
P3_2 = bit2;
P3_3 = bit3;
P3_4 = bit4;
P1 = ma;
}
void main()
{ unsigned char i,j,k;
dongchuchay();
while (1)
{
for (i=0;i<24;i++)
{
for (k=0;k<40;k++) //Tre 1s
{
for (j=0;j<=i;j++)
hiencot(dong[0][j],23-i+j);
delay(1); // Tre 1ms
}
}
for (i=0;i<100;i++)
{
for (k=0;k<40;k++) //Tre 1s
{
for (j=0;j<24;j++)
hiencot(dong[0][24-j+i],23-j);
delay(1); // Tre 1ms
}
}
}
}
em cám ơn trước
#include "AT89C51.h"
//--------------------------------------------------------------------
bdata unsigned char tmp;
sbit bit0 = tmp^0;
sbit bit1 = tmp^1;
sbit bit2 = tmp^2;
sbit bit3 = tmp^3;
sbit bit4 = tmp^4;
bit time0;
unsigned char dong[52][5];
unsigned char bangma[130] = {
0x3F,0x50,0x90,0x50,0x3F,//A
0xFF,0x99,0x99,0x66,0x00,//B
0x7E,0x81,0x81,0x81,0x42,//C
0xFF,0x81,0x81,0x42,0x3C,//D
0xFF,0x91,0x91,0x91,0x81,//E
0xFF,0x90,0x90,0x90,0x80,//F
0x7E,0x81,0x89,0x4F,0x08,//G
0xFF,0x10,0x10,0x10,0xFF,//H
0x81,0x81,0xFF,0x81,0x81,//I
0x87,0x81,0xFF,0x80,0x80,//J
0xFF,0x28,0x44,0x82,0x01,//K
0xFF,0x01,0x01,0x01,0x01,//L
0xFF,0x40,0x20,0x40,0xFF,//M
0xFF,0x20,0x08,0x02,0xFF,//N
0x7E,0x81,0x81,0x81,0x7E,//O
0xFF,0x88,0x88,0x88,0x70,//P
0x7E,0x81,0x85,0x7E,0x01,//Q
0xFF,0x98,0x94,0x62,0x01,//R
0x62,0x91,0x91,0x91,0x4E,//S
0x80,0x80,0xFF,0x80,0x80,//T
0xFE,0x01,0x01,0x01,0xFE,//U
0xF0,0x04,0x01,0x04,0xF0,//V
0xFE,0x01,0x0E,0x01,0xFE,//W
0xC3,0x24,0x18,0x24,0xC3,//X
0x80,0x40,0x3F,0x40,0x80,//Y
0x87,0x89,0x91,0xA1,0xC1//Z
};
unsigned char title[50] = "Chuc mung nam moi";
//------------------------------------------------------------------------------------------------
void Timer0_ISR(void) interrupt 1
{
EA = 0;
ET0 = 0;
IE0 = 0;
time0 = 0;
TR0=0; //stop time0
TF0=0;
return;
}
void delay(unsigned char n) /* do nothing n*1ms */
{
unsigned char j;
j=n;
do
{ EA = 1;
ET0 = 1;
IE0 = 1;
TL0=(65535-921)&0xff; // set time0 = 1ms
TH0=(65535-921)>>8;
TR0=1; // start time0
time0 = 1;
while (time0){}
}
while (--j!=0);
}
void trabang(unsigned char vitri,m)
{
unsigned char v,n,l;
v = vitri;
l = m;
for (n=0;n<5;n++)
dong[l][n] = bangma[v+n];
}
void dongchuchay(void)
{
unsigned char m;
for (m = 0; m < 50; m++)
{
switch (title[m])
{
case ('A'): trabang(0,m); break;
case ('a'): trabang(0,m); break;
case ('B'): trabang(5,m); break;
case ('b'): trabang(5,m); break;
case ('C'): trabang(10,m); break;
case ('c'): trabang(10,m); break;
case ('D'): trabang(15,m); break;
case ('d'): trabang(15,m); break;
case ('E'): trabang(20,m); break;
case ('e'): trabang(20,m); break;
case ('F'): trabang(25,m); break;
case ('f'): trabang(25,m); break;
case ('G'): trabang(30,m); break;
case ('g'): trabang(30,m); break;
case ('H'): trabang(35,m); break;
case ('h'): trabang(35,m); break;
case ('I'): trabang(40,m); break;
case ('i'): trabang(40,m); break;
case ('J'): trabang(45,m); break;
case ('j'): trabang(45,m); break;
case ('K'): trabang(50,m); break;
case ('k'): trabang(50,m); break;
case ('L'): trabang(55,m); break;
case ('l'): trabang(55,m); break;
case ('M'): trabang(60,m); break;
case ('m'): trabang(60,m); break;
case ('N'): trabang(65,m); break;
case ('n'): trabang(65,m); break;
case ('O'): trabang(70,m); break;
case ('o'): trabang(70,m); break;
case ('P'): trabang(75,m); break;
case ('p'): trabang(75,m); break;
case ('Q'): trabang(80,m); break;
case ('q'): trabang(80,m); break;
case ('R'): trabang(85,m); break;
case ('r'): trabang(85,m); break;
case ('S'): trabang(90,m); break;
case ('s'): trabang(90,m); break;
case ('T'): trabang(95,m); break;
case ('t'): trabang(95,m); break;
case ('U'): trabang(100,m); break;
case ('u'): trabang(100,m); break;
case ('V'): trabang(105,m); break;
case ('v'): trabang(105,m); break;
case ('W'): trabang(110,m); break;
case ('w'): trabang(110,m); break;
case ('X'): trabang(115,m); break;
case ('x'): trabang(115,m); break;
case ('Y'): trabang(120,m); break;
case ('y'): trabang(120,m); break;
case ('Z'): trabang(125,m); break;
case ('z'): trabang(125,m); break;
}
}
}
//--------------------------------------------------------------------
void hiencot(unsigned char ma, unsigned char cot)
{
tmp = cot;//+1;
P1 = 0x00;
P3_0 = bit0;
P3_1 = bit1;
P3_2 = bit2;
P3_3 = bit3;
P3_4 = bit4;
P1 = ma;
}
void main()
{ unsigned char i,j,k;
dongchuchay();
while (1)
{
for (i=0;i<24;i++)
{
for (k=0;k<40;k++) //Tre 1s
{
for (j=0;j<=i;j++)
hiencot(dong[0][j],23-i+j);
delay(1); // Tre 1ms
}
}
for (i=0;i<100;i++)
{
for (k=0;k<40;k++) //Tre 1s
{
for (j=0;j<24;j++)
hiencot(dong[0][24-j+i],23-j);
delay(1); // Tre 1ms
}
}
}
}
Comment