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 Hỏi xin sơ đồ tivi các loạibởi Trân thànhCần các Bạn giúp sơ đồ Lcd Samsung UA40JU6400 và UA43ku6500k. Xin cảm ơn!...
-
Channel: Điện tử truyền hình
Hôm qua, 16:07 -
-
Trả lời cho Hỏi xin sơ đồ tivi các loạibởi Trân thànhCần các Bạn giúp sơ đồ Lcd Samsung UA40JU6400 và UA43ku6500k. Xin cảm ơn!...
-
Channel: Điện tử truyền hình
Hôm qua, 16:01 -
-
bởi chinhnguyen9Hoạt động của thế hệ mạch cân bằng trước đây dựa trên nguyên lý so áp giữa 2 string liền kề. Hoạt động cân bằng chỉ kích hoạt khi sự chênh lệch vượt ngưỡng 100mV và ngưng hoạt động khi mức chênh lệch giảm xuống còn 30mV. Bản...
-
Channel: Điện tử dành cho người mới bắt đầu
27-04-2024, 05:07 -
-
bởi chinhnguyen9Xem hình minh họa có phần thuyết minh bên trong tiện việc quan sát và đọc thuyết minh. Khi G1 high dòng điện chạy theo các đường màu đen khi G2 high dòng điện chạy theo các đường màu nâu đỏ.
Bổ sung một tính chất củng cố cho tên gọi tụ bay: Trong mạch đề cập chỉ...-
Channel: Điện tử dành cho người mới bắt đầu
26-04-2024, 21:02 -
-
bởi chinhnguyen9Sản phẩm này ghi version 2.0 01-2024 MADE IN CHINA nhưng không thấy thương hiệu hình 1
Do 8 chân G của 8 mosfet được đấu song song thành 2 nhóm nên có cùng biên độ xung kích 12V. Nhưng Q1 và Q2 nằm cuối dãy, chân S cùa chúng có điện áp DC cao đến...-
Channel: Điện tử dành cho người mới bắt đầu
26-04-2024, 20:37 -
-
bởi xuanthiettivi em bị mất remote lỡ vào chế độ usb giờ không chọn lại source được. ai có file nạp cho em xin với ạ. Model 32HD957T2
-
Channel: Điện tử truyền hình
26-04-2024, 10:53 -
-
Trả lời cho Giải thích nôm na từ "tụ bay"bởi chinhnguyen9Đa tạ lời cảm ơn của bạn. Mến!
-
Channel: Hướng dẫn sử dụng diễn đàn
26-04-2024, 05:06 -
-
Trả lời cho Xin tư vấn về mạch cầu H cho inverter 1000wbởi thebinhzChắc là không được đâu bạn ơi
Quán ăn Vĩnh Yên-
Channel: Điện tử công suất
25-04-2024, 21:56 -
-
Trả lời cho Giải thích nôm na từ "tụ bay"bởi thebinhzCảm ơn bạn nhiều nha
Nhà hàng Vĩnh Yên-
Channel: Hướng dẫn sử dụng diễn đàn
25-04-2024, 21:50 -
-
bởi chinhnguyen9Vai viết này đã được chuyển sang chuyên mục phù hợp....
-
Channel: Hướng dẫn sử dụng diễn đàn
25-04-2024, 08:29 -
Comment