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
-
bởi nhathung1101Wrong translate! I don't care!
-
Channel: Điện tử dành cho người mới bắt đầu
hôm nay, 17:52 -
-
Trả lời cho Kiểm tra biến ápbởi nhathung1101Tôi viết bài này để anh em hiểu:
Cái loại Cty không có thiết bị chuyên dùng thì chỉ sang Tề Lỗ (Vĩnh Phúc) hoặc Văn Môn (Hưng Yên).
Vớ vẩn đừng trình bày....-
Channel: Điện tử dành cho người mới bắt đầu
hôm nay, 17:42 -
-
Trả lời cho Kiểm tra biến ápbởi nhathung1101Ở trên Tề Lỗ (Vĩnh Phúc) có dịch vụ này mà. Họ cắt đôi ra rồi đếm. Hoặc tách ra rồi cân.
-
Channel: Điện tử dành cho người mới bắt đầu
hôm nay, 17:37 -
-
Trả lời cho Yêu thơ mê nhạc, mời các bác vào đây!bởi nhathung1101Lão lại bảo thủ. Giờ giới trẻ chơi 4/5 cơ.
Nó pha tạp thành "đít cô cha" còn gọi sang chảnh là Ca bóp hay Cu bóp gì đó hay đít ...
ha ha... Già rồi không thưởng nổi.
Chứ làm gì còn thời chúng ta chứ!
...-
Channel: Tâm tình dân kỹ thuật
hôm nay, 17:27 -
-
Trả lời cho Máy ảnh máy tính xách tay không hoạt độngbởi pia2k1Mang quán quán sửa ngta xem cho bạn ạ...
-
Channel: Camera và xử lý ảnh
hôm nay, 13:45 -
-
Trả lời cho Kiểm tra biến ápbởi bqvietNgười tàu bán máy này sang VN nhiều phết, ví dụ hàng của hãng GainKaiTa gì đó đủ loại từ đơn giản tới phức tạp
http://en.gkt.com.cn/
Kiểu 3259 cũ chẳng hạn, nhiều tính năng mà vẫn tương đối nhỏ gọn.-
Channel: Điện tử dành cho người mới bắt đầu
Hôm qua, 00:15 -
-
bởi lamvu0677Chào mọi người, e làm trong cty về biến áp , toàn mấy con nhỏ nhỏ, làm sao để mình có thể kiểm tra nhanh số vòng dây của mỗi cuộn , đầu vào đầu ra của dây, có thiết bị gì nhỏ gọn hỗ trợ việc này không ạ , xin cảm ơn...
-
Channel: Điện tử dành cho người mới bắt đầu
12-05-2024, 07:15 -
-
Trả lời cho Yêu thơ mê nhạc, mời các bác vào đây!bởi vi van phamNhịp 2/4 1 trường canh có 2 nốt đen. Nhịp 3/4 1 trường canh có 3 nốt đen. Nhịp 4/4 1 trường canh có 4 nốt đen.
Các điệu nhạc sẽ có âm bass ở phách mạnh. Dồn 2 trường canh 2/4 thành 4/4 chơi điệu chachacha, nghe "kỳ cục" lắm....-
Channel: Tâm tình dân kỹ thuật
08-05-2024, 07:05 -
Comment