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
-
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
-
Nguyê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
-
Trả lời cho Kiểm tra biến ápbởi lamvu0677nhân tiện cho mình hỏi thêm về cái phần test hipot (cao áp),là để kiểm tra độ bền cách điện giưa các cuộn dây,mà thấy thông số test thường ở mức 4kvac,vậy nếu mấy con fail đó xài bình thường vẫn dduocj phải không ạ,vì điện mình làm gì lên tới mức đó
-
Channel: Điện tử dành cho người mới bắt đầu
10-11-2024, 08:52 -
-
Trả lời cho Kiểm tra biến ápbởi lamvu0677máy đo số vòng thì cty có ,mà nó to quá,tưởng có máy nào gọn gọn bỏ túi được thì tiện hơn,vì đi lại nhiều...
-
Channel: Điện tử dành cho người mới bắt đầu
10-11-2024, 08:47 -
-
bởi tmcodonMình thấy diễn đàn có chuyên mục quảng cáo rồi mà. Bạn đóng góp để mở luồng riêng
-
Channel: Hướng dẫn sử dụng diễn đàn
09-11-2024, 13:36 -
-
bởi Nicole08Xin chào mọi người, tôi đã sử dụng Flashforge Inventor 2 được gần 5 năm và rất hài lòng với nó, nhưng tuần trước đã xảy ra sự cố. Có vẻ như động cơ bước đưa sợi in vào đầu nóng đã bị hỏng. Mọi thứ khác có vẻ ổn trên máy...
-
Channel: Điện tử dành cho người mới bắt đầu
09-11-2024, 12:55 -
Comment