#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit L1=P3^0;
sbit L2=P3^1;
sbit L3=P3^2;
sbit L4=P3^3;
unsigned char LED;
void delay(uint t)
{
uchar i;
while(t--)
{
for(;i<200;i++);
}
}
void key_scan (void)
{
if(L1==0)
LED=0;
if(L2==0)
LED=1;
if(L3==0)
LED=2;
if(LED==0)
LED=3;
}
void forward(void)
{
P1=0xff;
delay(200);
P1=0x00;
delay(100);
}
void backward()
{
P1=0xff;
}
void blink(void)
{
P1=0xfe;
{
while(1)
{
delay(200);
P1=_crol_(P1,1);
}
}
}
void alter(void)
{
P1=0x7f;
{
while (1)
{
delay(200);
P1=_cror_(P1,1);
}
}
}
void main(void)
{
switch (LED)
{
case 0: forward();break;
case 1:backward();break;
case 2:blink() ; break;
case 3:alter (); break;
}
}
Build target 'Target 1'
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?KEY_SCAN?蟔蘝3
Program Size: data=11.0 xdata=0 code=156
crea
ting hex file from "习题3"...
"习题3" - 0 Error(s), 1 Warning(s).
改了一下,没啥错误了,谢谢
一周热门 更多>