Cám ơn ban NgoHaiBac về bài viết trên . Mình mới vừa chập chững bước vào phần mềm này . Mong bạn hướng dẫn tiếp . Cám ơn nhiều .
Thông báo
Collapse
No announcement yet.
HƯỚNG DẪN LẬP TRÌNH KEIL C CHO 8051-[Chỉ dành post bài hướng dẫn]
Collapse
X
-
sự khác nhau giữa việc khai báo sbit với truyền thẳng giá trị vào Port P0=0xaa là ntn vậy bạn ???? lúc nào thì dùng được lện P0=0xaa vậy ???Nguyên văn bởi tntiam Xem bài viết#include <REGX52.H>
#include <stdlib.h>
unsigned int i,j,k,n;
sbit c1 = P1^0;
sbit c2 = P1^1;
sbit c3 = P1^2;
sbit c4 = P1^3;
sbit c5 = P1^4;
sbit c6 = P1^5;
sbit c7 = P1^6;
sbit c8 = P1^7;
sbit c9 = P2^0;
sbit c10 = P2^1;
sbit c11 = P2^2;
sbit c12 = P2^3;
sbit c13 = P2^4;
sbit c14 = P2^5;
sbit c15 = P2^6;
sbit c16 = P2^7;
sbit c17 = P3^0;
sbit c18 = P3^1;
sbit c19 = P3^2;
sbit c20 = P3^3;
sbit c21 = P3^4;
sbit c22 = P3^5;
sbit c23 = P3^6;
sbit c24 = P3^7;
sbit c25 = P0^7;
sbit L1 = P0^4;
sbit L2 = P0^3;
sbit L3 = P0^2;
sbit L4 = P0^1;
sbit L5 = P0^0;
//=======================================
void tre(unsigned int t)
{
unsigned int i;
for(i=0;i<=t;i++);
}
//---------------------------------------
void tatcacot()
{
P1=P2=P3=0x00;c25=0;
}
//---------------------------------------
void xoatatcacot()
{
P1=P2=P3=0xff;c25=1;
}
//---------------------------------------
void xoa()
{
P0=P1=P2=P3=0xff;
}
//---------------------------------------
void toara(unsigned int time, unsigned char n)
{
xoa();
for(i=0;i<=n;i++)
{
L1=L2=L3=L4=L5=0;c13=0;tre(time);
xoa();
L1=L2=L3=L4=L5=0;c7=c8=c9=c12=c14=c17=c18=c19=0;tr e(time);
xoa();
L1=L2=L3=L4=L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c2 4=c23=c22=c21=c16=c11=c6=0;tre(time);
xoa();
}
}
//----------------------------------------
void sangdan(unsigned int time, unsigned char n)
{
for(i=0;i<=n;i++)
{
xoa();
L1=L2=L3=L4=L5=0;
c13=0;tre(time);c18=0;tre(time);c19=0;tre(time);c1 4=0;tre(time);
c9=0; tre(time);c8=0; tre(time);c7=0; tre(time);c12=0;tre(time);
c17=0;tre(time);c22=0;tre(time);c23=0;tre(time);c2 4=0;tre(time);
c25=0;tre(time);c20=0;tre(time);c15=0;tre(time);c1 0=0;tre(time);
c5=0; tre(time);c4=0; tre(time);c3=0; tre(time);c2=0; tre(time);
c1=0; tre(time);c6=0; tre(time);c11=0;tre(time);c16=0;tre(time);
c21=0;tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c21=0;tre(time);
c16=0;tre(time);c11=0;tre(time); c6=0; tre(time);c1=0; tre(time);
c2=0; tre(time);c3=0; tre(time);c4=0; tre(time);c5=0; tre(time);
c10=0;tre(time);c15=0;tre(time);c20=0;tre(time);c2 5=0;tre(time);
c24=0;tre(time);c23=0;tre(time);c22=0;tre(time);c1 7=0;tre(time);
c12=0;tre(time);c7=0; tre(time);c8=0; tre(time);c9=0; tre(time);
c14=0;tre(time);c19=0;tre(time);c18=0;tre(time);c1 3=0;tre(time);
}
}
//----------------------------------------
void nuocdang(unsigned int time, unsigned char n)
{
unsigned char M[5]={0xfe,0xfd,0xfb,0xf7,0xef};
xoa();
for(i=0;i<=n;i++)
{
for(j=0;j<=4;j++)
{
P0=M[j];
tatcacot();
tre(time);
}
}
}
//----------------------------------------
void choptat(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
P0=P1=P2=P3=0;tre(time);
xoa();tre(time);
}
}
//----------------------------------------
void quaydung(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
xoa();
L1=L2=L3=L4=L5=0;
c11=c12=c13=c14=c15=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c6=c13=c20=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c1=c7=c13=c19=c25=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c2=c13=c24=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c3=c8=c13=c18=c23=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c4=c13=c22=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c5=c9=c13=c17=c21=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c16=c13=c10=0;
tre(time);
}
}
//----------------------------------------
void quaydung2(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
xoa();
L1=L2=L3=L4=L5=0;
c11=c12=c13=c14=c15=0;
c3=c8=c13=c18=c23=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c6=c13=c20=0;
c22=c13=c4=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c1=c7=c13=c19=c25=0;
c21=c17=c13=c9=c5=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c2=c13=c24=0;
c16=c13=c10=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c3=c8=c13=c18=c23=0;
c11=c12=c13=c14=c15=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c4=c13=c22=0;
c6=c13=c20=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c5=c9=c13=c17=c21=0;
c1=c7=c13=c19=c25=0;
tre(time);
xoa();
L1=L2=L3=L4=L5=0;
c16=c13=c10=0;
c2=c13=c24=0;
tre(time);
}
}
//----------------------------------------
void xeptang(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
xoa();
L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
L4=L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22 =c21=c16=c11=c6=0;tre(time);
L3=L4=L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23= c22=c21=c16=c11=c6=0;tre(time);
L2=L3=L4=L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c 23=c22=c21=c16=c11=c6=0;tre(time);
L1=L2=L3=L4=L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c2 4=c23=c22=c21=c16=c11=c6=0;tre(time);
}
}
//----------------------------------------
void luonsong(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
xoa();
for(k=0;k<time;k++)
{
L5=0;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=0;tre(50);
L5=1;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=1;tre(50);
L4=0;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=0;tre(50) ;
L4=1;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=1;tre(50) ;
L1=0;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=0;tre(50);
L1=1;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=1;tre(50);
L2=0;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=0;tre(50) ;
L2=1;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=1;tre(50) ;
}
for(k=0;k<time;k++)
{
L4=0;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=0;tre(50);
L4=1;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=1;tre(50);
L5=0;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=0;tre(50) ;
L5=1;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=1;tre(50) ;
L2=0;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=0;tre(50);
L2=1;c1=c2=c3=c4=c5=c11=c12=c13=c14=c15=c21=c22=c2 3=c24=c25=1;tre(50);
L1=0;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=0;tre(50) ;
L1=1;c6=c7=c8=c9=c10=c16=c17=c18=c19=c20=1;tre(50) ;
}
}
}
//----------------------------------------
void chu_I(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c1=c2=c3=c4=c5=0;tre(20);
xoa();
L2=0;c3=0;tre(20);
xoa();
L3=0;c3=0;tre(20);
xoa();
L4=0;c3=0;tre(20);
xoa();
L5=0;c1=c2=c3=c4=c5=0;tre(20);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c6=c7=c8=c9=c10=0;tre(20);
xoa();
L2=0;c8=0;tre(20);
xoa();
L3=0;c8=0;tre(20);
xoa();
L4=0;c8=0;tre(20);
xoa();
L5=0;c6=c7=c8=c9=c10=0;tre(20);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L2=0;c13=0;tre(20);
xoa();
L3=0;c13=0;tre(20);
xoa();
L4=0;c13=0;tre(20);
xoa();
L5=0;c11=c12=c13=c14=c15=0;tre(20);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c16=c17=c18=c19=c20=0;tre(20);
xoa();
L2=0;c18=0;tre(20);
xoa();
L3=0;c18=0;tre(20);
xoa();
L4=0;c18=0;tre(20);
xoa();
L5=0;c16=c17=c18=c19=c20=0;tre(20);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c21=c22=c23=c24=c25=0;tre(20);
xoa();
L2=0;c23=0;tre(20);
xoa();
L3=0;c23=0;tre(20);
xoa();
L4=0;c23=0;tre(20);
xoa();
L5=0;c21=c22=c23=c24=c25=0;tre(20);
}
}
}
//----------------------------------------
void chu_L(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c1=c2=c3=c4=c5=0;tre(50);
xoa();
L2=0;c1=0;tre(50);
xoa();
L3=0;c1=0;tre(50);
xoa();
L4=0;c1=0;tre(50);
xoa();
L5=0;c1=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c6=c7=c8=c9=c10=0;tre(50);
xoa();
L2=0;c6=0;tre(50);
xoa();
L3=0;c6=0;tre(50);
xoa();
L4=0;c6=0;tre(50);
xoa();
L5=0;c6=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c11=c12=c13=c14=c15=0;tre(50);
xoa();
L2=0;c11=0;tre(50);
xoa();
L3=0;c11=0;tre(50);
xoa();
L4=0;c11=0;tre(50);
xoa();
L5=0;c11=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c16=c17=c18=c19=c20=0;tre(50);
xoa();
L2=0;c16=0;tre(50);
xoa();
L3=0;c16=0;tre(50);
xoa();
L4=0;c16=0;tre(50);
xoa();
L5=0;c16=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c21=c22=c23=c24=c25=0;tre(50);
xoa();
L2=0;c21=0;tre(50);
xoa();
L3=0;c21=0;tre(50);
xoa();
L4=0;c21=0;tre(50);
xoa();
L5=0;c21=0;tre(50);
}
}
}
//----------------------------------------
void chu_O(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c2=c3=c4=0;tre(50);
xoa();
L2=0;c1=c5=0;tre(50);
xoa();
L3=0;c1=c5=0;tre(50);
xoa();
L4=0;c1=c5=0;tre(50);
xoa();
L5=0;c2=c3=c4=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c7=c8=c9=0;tre(50);
xoa();
L2=0;c6=c10=0;tre(50);
xoa();
L3=0;c6=c10=0;tre(50);
xoa();
L4=0;c6=c10=0;tre(50);
xoa();
L5=0;c7=c8=c9=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c12=c13=c14=0;tre(50);
xoa();
L2=0;c11=c15=0;tre(50);
xoa();
L3=0;c11=c15=0;tre(50);
xoa();
L4=0;c11=c15=0;tre(50);
xoa();
L5=0;c12=c13=c14=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c17=c18=c19=0;tre(50);
xoa();
L2=0;c16=c20=0;tre(50);
xoa();
L3=0;c16=c20=0;tre(50);
xoa();
L4=0;c16=c20=0;tre(50);
xoa();
L5=0;c17=c18=c19=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c22=c23=c24=0;tre(50);
xoa();
L2=0;c21=c25=0;tre(50);
xoa();
L3=0;c21=c25=0;tre(50);
xoa();
L4=0;c21=c25=0;tre(50);
xoa();
L5=0;c22=c23=c24=0;tre(50);
}
}
}
//----------------------------------------
void chu_V(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c3=0;tre(50);
xoa();
L2=0;c2=c4=0;tre(50);
xoa();
L3=0;c1=c5=0;tre(50);
xoa();
L4=0;c1=c5=0;tre(50);
xoa();
L5=0;c1=c5=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c8=0;tre(50);
xoa();
L2=0;c7=c9=0;tre(50);
xoa();
L3=0;c6=c10=0;tre(50);
xoa();
L4=0;c6=c10=0;tre(50);
xoa();
L5=0;c6=c10=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c13;tre(50);
xoa();
L2=0;c12=c14=0;tre(50);
xoa();
L3=0;c11=c15=0;tre(50);
xoa();
L4=0;c11=c15=0;tre(50);
xoa();
L5=0;c11=c15=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c18=0;tre(50);
xoa();
L2=0;c17=c19=0;tre(50);
xoa();
L3=0;c16=c20=0;tre(50);
xoa();
L4=0;c16=c20=0;tre(50);
xoa();
L5=0;c16=c20=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c23=0;tre(50);
xoa();
L2=0;c22=c24=0;tre(50);
xoa();
L3=0;c21=c25=0;tre(50);
xoa();
L4=0;c21=c25=0;tre(50);
xoa();
L5=0;c21=c25=0;tre(50);
}
}
}
//----------------------------------------
void chu_E(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c1=c2=c3=c4=c5=0;tre(50);
xoa();
L2=0;c1=0;tre(50);
xoa();
L3=0;c1=c2=c3=c4=c5=0;tre(50);
xoa();
L4=0;c1=0;tre(50);
xoa();
L5=0;c1=c2=c3=c4=c5=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c6=c7=c8=c9=c10=0;tre(50);
xoa();
L2=0;c6=0;tre(50);
xoa();
L3=0;c6=c7=c8=c9=c10=0;tre(50);
xoa();
L4=0;c6=0;tre(50);
xoa();
L5=0;c6=c7=c8=c9=c10=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c11=c12=c13=c14=c15=0;tre(50);
xoa();
L2=0;c11=0;tre(50);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(50);
xoa();
L4=0;c11=0;tre(50);
xoa();
L5=0;c11=c12=c13=c14=c15=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c16=c17=c18=c19=c20=0;tre(50);
xoa();
L2=0;c16=0;tre(50);
xoa();
L3=0;c16=c17=c18=c19=c20=0;tre(50);
xoa();
L4=0;c16=0;tre(50);
xoa();
L5=0;c16=c17=c18=c19=c20=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c21=c22=c23=c24=c25=0;tre(50);
xoa();
L2=0;c21=0;tre(50);
xoa();
L3=0;c21=c22=c23=c24=c25=0;tre(50);
xoa();
L4=0;c21=0;tre(50);
xoa();
L5=0;c21=c22=c23=c24=c25=0;tre(50);
}
}
}
//----------------------------------------
void chu_Y(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c1=0;tre(50);
xoa();
L2=0;c2=0;tre(50);
xoa();
L3=0;c3=0;tre(50);
xoa();
L4=0;c2=c4=0;tre(50);
xoa();
L5=0;c1=c5=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c6=0;tre(50);
xoa();
L2=0;c7=0;tre(50);
xoa();
L3=0;c8=0;tre(50);
xoa();
L4=0;c7=c9=0;tre(50);
xoa();
L5=0;c6=c10=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c11=0;tre(50);
xoa();
L2=0;c12=0;tre(50);
xoa();
L3=0;c13=0;tre(50);
xoa();
L4=0;c12=c14=0;tre(50);
xoa();
L5=0;c11=c15=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c16=0;tre(50);
xoa();
L2=0;c17=0;tre(50);
xoa();
L3=0;c18=0;tre(50);
xoa();
L4=0;c17=c19=0;tre(50);
xoa();
L5=0;c16=c20=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c21=0;tre(50);
xoa();
L2=0;c22=0;tre(50);
xoa();
L3=0;c23=0;tre(50);
xoa();
L4=0;c22=c24=0;tre(50);
xoa();
L5=0;c21=c25=0;tre(50);
}
}
}
//----------------------------------------
void chu_U(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
//1
for(k=0;k<time;k++)
{
xoa();
L1=0;c2=c3=c4=0;tre(50);
xoa();
L2=0;c1=c5=0;tre(50);
xoa();
L3=0;c1=c5=0;tre(50);
xoa();
L4=0;c1=c5=0;tre(50);
xoa();
L5=0;c1=c5=0;tre(50);
}
//2
for(k=0;k<time;k++)
{
xoa();
L1=0;c7=c8=c9=0;tre(50);
xoa();
L2=0;c6=c10=0;tre(50);
xoa();
L3=0;c6=c10=0;tre(50);
xoa();
L4=0;c6=c10=0;tre(50);
xoa();
L5=0;c6=c10=0;tre(50);
}
//3
for(k=0;k<time;k++)
{
xoa();
L1=0;c12=c13=c14=0;tre(50);
xoa();
L2=0;c11=c15=0;tre(50);
xoa();
L3=0;c11=c15=0;tre(50);
xoa();
L4=0;c11=c15=0;tre(50);
xoa();
L5=0;c11=c15=0;tre(50);
}
//4
for(k=0;k<time;k++)
{
xoa();
L1=0;c17=c18=c19=0;tre(50);
xoa();
L2=0;c16=c20=0;tre(50);
xoa();
L3=0;c16=c20=0;tre(50);
xoa();
L4=0;c16=c20=0;tre(50);
xoa();
L5=0;c16=c20=0;tre(50);
}
//5
for(k=0;k<time;k++)
{
xoa();
L1=0;c22=c23=c24=0;tre(50);
xoa();
L2=0;c21=c25=0;tre(50);
xoa();
L3=0;c21=c25=0;tre(50);
xoa();
L4=0;c21=c25=0;tre(50);
xoa();
L5=0;c21=c25=0;tre(50);
}
}
}
//----------------------------------------
void phaohoa(unsigned int time,unsigned char n)
{
xoa();
for(i=0;i<n;i++)
{
xoa();
L3=0;c13=0;
tre(time);
for(k=0;k<100;k++)
{
xoa();
L2=0;c7=c8=c9=c14=c19=c18=c17=c12=0;tre(50);
xoa();
L3=0;c7=c8=c9=c14=c19=c18=c17=c12=0;tre(50);
xoa();
L4=0;c7=c8=c9=c14=c19=c18=c17=c12=0;tre(50);
}
tre(time);
for(k=0;k<100;k++)
{
xoa();
L1=0;tatcacot();tre(50);
xoa();
L2=0;tatcacot();tre(50);
xoa();
L3=0;tatcacot();tre(50);
xoa();
L4=0;tatcacot();tre(50);
xoa();
L5=0;tatcacot();tre(50);
}
tre(time);
}
}
//----------------------------------------
void quayngang(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
for(k=0;k<time;k++)
{
xoa();
L3=0;tatcacot();tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L2=0;c1=c2=c3=c4=c5=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L4=0;c21=c22=c23=c24=c25=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L1=0;c1=c2=c3=c4=c5=0;tre(20);
xoa();
L2=0;c6=c7=c8=c9=c10=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L4=0;c16=c17=c18=c19=c20=0;tre(20);
xoa();
L5=0;c21=c22=c23=c24=c25=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L1=0;c6=c7=c8=c9=c10=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L5=0;c16=c17=c18=c19=c20=c25=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L1=L2=L3=L4=L5=0;c11=c12=c13=c14=c15=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L1=0;c16=c17=c18=c19=c20=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L5=0;c6=c7=c8=c9=c10=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L1=0;c21=c22=c23=c24=c25=0;tre(20);
xoa();
L2=0;c16=c17=c18=c19=c20=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L4=0;c6=c7=c8=c9=c10=0;tre(20);
xoa();
L5=0;c1=c2=c3=c4=c5=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L2=0;c21=c22=c23=c24=c25=0;tre(20);
xoa();
L3=0;c11=c12=c13=c14=c15=0;tre(20);
xoa();
L4=0;c1=c2=c3=c4=c5=0;tre(20);
}
for(k=0;k<time;k++)
{
xoa();
L3=0;tatcacot();tre(20);
}
}
}
//----------------------------------------
void banphao(unsigned int time,unsigned char n)
{
for(i=0;i<n;i++)
{
xoa();
c13=0;L1=0;tre(time);L1=1;L2=0;tre(time);L2=1;
L3=0;tre(time);L3=1;L4=0;tre(time);L4=1;L5=0;tre(t ime);L5=1;
xoa();
L5=0;c7=c8=c9=c14=c19=c18=c17=c12=0;tre(time);
xoa();
L5=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
xoa();
L4=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
xoa();
L3=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
xoa();
L2=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
xoa();
L1=0;c1=c2=c3=c4=c5=c10=c15=c20=c25=c24=c23=c22=c2 1=c16=c11=c6=0;tre(time);
}
}
//========================================
void main()
{
while(1)
{
toara(20000,5);
sangdan(10000,1);
nuocdang(15000,3);
nuocdang(10000,3);
nuocdang(5000,5);
nuocdang(3000,5);
quaydung(20000,3);
quaydung(10000,3);
quaydung(5000,5);
quaydung(3000,10);
choptat(10000,5);
xeptang(30000,5);
luonsong(50,10);
chu_I(50,1);
chu_L(50,1);
chu_O(50,1);
chu_V(50,1);
chu_E(50,1);
chu_Y(50,1);
chu_O(50,1);
chu_U(50,1);
phaohoa(8000,5);
quayngang(100,10);
quayngang(50,20);
toara(20000,3);
quaydung2(20000,5);
quaydung2(10000,8);
banphao(8000,10);
chu_I(50,1);
chu_L(50,1);
chu_O(50,1);
chu_V(50,1);
chu_E(50,1);
chu_Y(50,1);
chu_O(50,1);
chu_U(50,1);
banphao(8000,10);
}
}
//trên là ct viết cho 89s52 điều khiển led cube 5x5x5. em lấy nguyên văn trên mạng rồi về chạy sang file .H nhưng không được.
Comment
-
thì bỏ jmp đi cko khoi lặp ạiNguyên văn bởi an_87pt Xem bài viếtCác anh giứp em ,mã code asm này với ! Em còn gà lắm . Em muốn nó chạy từ đầu đến cuối chương trình rồi nó kết thúc . " ko lập lại chu kỳ cám ơn " ! em phải thêm gì ở đâu và sửa như thế nào ?
ORG 0000H
;================================================= =========================
BAT_DAU_NHAY:
;Dong:1
MOV P0,#00000001B
CALL Delay_2
;Dong:2
MOV P0,#00000000B
CALL Delay_2
;Dong:3
MOV P0,#00001000B
CALL Delay_2
;Dong:4
MOV P0,#00000000B
CALL Delay_60
;Dong:5
MOV P0,#00000001B
CALL Delay_2
;Dong:6
MOV P0,#00000000B
CALL Delay_2
;Dong:7
MOV P0,#00000001B
CALL Delay_2
;Dong:8
MOV P0,#00000000B
CALL Delay_2
;Dong:9
MOV P0,#00000010B
CALL Delay_2
;Dong:10
MOV P0,#00000000B
CALL Delay_2
;Dong:11
MOV P0,#00000010B
CALL Delay_2
;Dong:12
MOV P0,#00000000B
CALL Delay_2
;Dong:13
MOV P0,#00000010B
CALL Delay_2
;Dong:14
MOV P0,#00000000B
CALL Delay_2
;Dong:15
MOV P0,#00000001B
CALL Delay_2
;Dong:16
MOV P0,#00000000B
CALL Delay_2
;Dong:17
MOV P0,#00000001B
CALL Delay_2
;Dong:18
MOV P0,#00000000B
CALL Delay_2
;Dong:19
MOV P0,#00000001B
CALL Delay_2
;Dong:20
MOV P0,#00000000B
CALL Delay_2
;Dong:21
MOV P0,#00000010B
CALL Delay_2
;Dong:22
MOV P0,#00000000B
CALL Delay_2
;Dong:23
MOV P0,#00000010B
CALL Delay_2
;Dong:24
MOV P0,#00000000B
CALL Delay_2
;Dong:25
MOV P0,#00000010B
CALL Delay_2
;Dong:26
MOV P0,#00000000B
CALL Delay_2
;Dong:27
MOV P0,#00000001B
CALL Delay_2
;Dong:28
MOV P0,#00000000B
CALL Delay_2
;Dong:29
MOV P0,#00000001B
CALL Delay_2
;Dong:30
MOV P0,#00000000B
CALL Delay_2
;Dong:31
MOV P0,#00000001B
CALL Delay_2
;Dong:32
MOV P0,#00000000B
CALL Delay_2
;Dong:33
MOV P0,#00000001B
CALL Delay_2
;Dong:34
MOV P0,#00000000B
CALL Delay_60
;Dong:35
MOV P0,#00001000B
CALL Delay_2
JMP BAT_DAU_NHAY
;================================================= ===============
;-------------------------------------
;Delay 2 buoc
Delay_2:
MOV R1,#2
MOV R2,#0
MOV R3,#0
lapDelay_2:
DJNZ R3,lapDelay_2
DJNZ R2,lapDelay_2
DJNZ R1,lapDelay_2
RET
;-------------------------------------
;Delay 60 buoc
Delay_60:
MOV R1,#60
MOV R2,#0
MOV R3,#0
lapDelay_60:
DJNZ R3,lapDelay_60
DJNZ R2,lapDelay_60
DJNZ R1,lapDelay_60
RET
END
Comment
-
#include <regx51.h>
#define led P2
#define XUNG P3_7
#define bam P3_5
int x;
///////
void delay()
{
while(XUNG==1)
{
}
while(XUNG==0)
{
}
}
//////
char effect[]={0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00};
void mau()
{
for(x=0;x<8;x++)
{
led = effect[x];
delay();
}
}
//////
void main()
{
while(1)
{
if (bam==0xff)
{
mau();
}
else
{
led=0xfe;
led=0xfd;
led=0xfb;
led=0xf7;
led=0xef;
led=0xdf;
led=0xbf;
led=0x7f;
}
}
}
Comment
Bài viết mới nhất
Collapse
-
bởi opthaianTrong quy trình sản xuất rượu, việc lựa chọn thiết bị chưng cất phù hợp không chỉ ảnh hưởng đến chất lượng thành phẩm mà còn quyết định hiệu quả kinh doanh lâu dài của mỗi xưởng sản xuất. Đặc biệt với các xưởng nhỏ, thách...
-
Channel: Góp ý cho diễn đàn
hôm nay, 12:00 -
-
Trả lời cho Xin hỏi về mạch thu FM/AM trong catsettebởi nguyendinhvanTheo tôi, nó chỉ là cái Tuy- ê - nơ, hoặc là khối Trung Văn Tần, nó một phần trong cái Da đì ô thôi. Vì có thấy một chỗ có ba chân hàn, giiống như chân Cờ rít sờ tăng 455 ki nô hẹc. Còn khối Tuy ê nơ thì không nhìn thây cái Di ốt Va di cáp...
-
Channel: Điện thanh
Hôm qua, 19:59 -
-
Trả lời cho Đấu tắt điện cho máy tính bảngbởi afrendlyCó vẻ ngoài hiểu biết của mình rồi. Cuối cùng mình quyết định tìm mua 2 pin trên Shopee, giá 200K thay vào. Tuy nhận pin được 1%, sạc mãi không vào nhưng cũng mở được máy lên. Vậy cũng tạm. Cảm ơn bạn đã hỗ trợ nhé....
-
Channel: Thiết bị điện tử cá nhân
04-12-2025, 01:27 -
-
Trả lời cho Máy điện châm ?bởi nick22Đúng như bạn nói, máy điện châm hiện nay trên thị trường đã khá đa dạng về mẫu mã, chức năng và giá thành.
-
Channel: Điện tử y sinh
01-12-2025, 13:23 -
-
Trả lời cho Làm thế nào để check IC LM358bởi thetungĐể check IC sống hay chết thì đơn giản : bạn lắp cái mạch ( khuếch đại hoặc dao động ) chạy bằng con IC đó ,nhưng vị trí IC thì lắp cái đế .... thế là cứ cắm rút thì biết . Còn không thì kiếm cái này : https://shopee.vn/Xu-M%C3%A1y-ki%E1%...di-%C4%91%E1%B...
-
Channel: Hướng dẫn tìm thông tin linh kiện
28-11-2025, 14:34 -
-
bởi ngochung90Tình hình là em có mua mạch 3s về để hàn vào khối pin 12v, hàn xong em đo tại các chân từ B-, B1, B2, B+ thì điện áp pin vẫn đủ 12,6v, nhưng tại 2 chân ra P- P+ thì đo chỉ được 6,3v là bị sao các bác, và chân P- P + này đồng thời là chân sạc xả thì mình cắm sạc xả cùng lúc được ko ạ
...-
Channel: Điện tử dành cho người mới bắt đầu
28-11-2025, 10:32 -
-
Trả lời cho Làm thế nào để check IC LM358bởi nguyendinhvanViệc đó tùy thuộc trình độ khoa học kỹ thuật công nghệ ứng dụng hiện tại thôi.
Trong datasheet,họ đưa ra nhiều thông số. Tùy theo khả năng , và những thông số họ cần, họ sẽ kiểm tra casc số đo có khớp với số liệu trong datasheet...-
Channel: Hướng dẫn tìm thông tin linh kiện
27-11-2025, 18:00 -
-
bởi kqbn9091Em có mạch AT89s8253 đang cần sửa số serial no của CHIP mà giờ lâu quá rồi không dùng keil nên không biết phải làm sao, trong khi chỉ còn file hex. Mạch nạp thì progris khi viết không sửa được số serial của IC. Rất cần bác nào còn làm về 89...
-
Channel: Vi điều khiển họ 8051
27-11-2025, 11:13 -

Comment