展开全部
/*******************************************************/
/*P1口LED流水灯实验 */
/*目标器件:AT89S51 */
/*晶振:11.0592MHZ */
/*编译环境:Keil 7.50A */
/*******************************************************/
#include <reg51.h>
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;
sbit LED4 = P1^3;
sbit LED5 = P1^4;
sbit LED6 = P1^5;
sbit LED7 = P1^6;
sbit LED8 = P1^7;
void Delay()
{
unsigned char i,j;
for(i=0;i<255;i++)
for(j=0;j<255;j++);
}
void main()
{
while(1)
{
P1 = 0xff;
LED1 = 0;
Delay();
LED2 = 0;
LED1 = 1;
Delay();
LED3 = 0;
LED2 = 1;
Delay();
LED4 = 0;
LED3 = 1;
Delay();
LED5 = 0;
LED4 = 1;
Delay();
LED6 = 0;
LED5 = 1;
Delay();
LED7 = 0;
LED6 = 1;
Delay();
LED8 = 0;
LED7 = 1;
Delay();
}
}
/*P1口LED流水灯实验 */
/*目标器件:AT89S51 */
/*晶振:11.0592MHZ */
/*编译环境:Keil 7.50A */
/*******************************************************/
#include <reg51.h>
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;
sbit LED4 = P1^3;
sbit LED5 = P1^4;
sbit LED6 = P1^5;
sbit LED7 = P1^6;
sbit LED8 = P1^7;
void Delay()
{
unsigned char i,j;
for(i=0;i<255;i++)
for(j=0;j<255;j++);
}
void main()
{
while(1)
{
P1 = 0xff;
LED1 = 0;
Delay();
LED2 = 0;
LED1 = 1;
Delay();
LED3 = 0;
LED2 = 1;
Delay();
LED4 = 0;
LED3 = 1;
Delay();
LED5 = 0;
LED4 = 1;
Delay();
LED6 = 0;
LED5 = 1;
Delay();
LED7 = 0;
LED6 = 1;
Delay();
LED8 = 0;
LED7 = 1;
Delay();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
org 0000h
mov a, #01h
start: mov P1, a
rl a
lcall Delay
ljmp start
Delay:
mov r6, #0
mov r7, #0
DelayLoop:
djnz r6, DelayLoop
djnz r7, DelayLoop
ret
end
mov a, #01h
start: mov P1, a
rl a
lcall Delay
ljmp start
Delay:
mov r6, #0
mov r7, #0
DelayLoop:
djnz r6, DelayLoop
djnz r7, DelayLoop
ret
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询