8051f330单片机怎么通过HC138控制LED亮灭,求大神帮修改
时间:10-02
整理:3721RD
点击:
#include<c8051f330.h>
#define uchar unsigned char
void Delay()
{
uchar a,b;
for(a=0;a<20;a++)
for(b=0;b<20;b++) ;
}
void SYSCLK_Init(void)
{
OSCICN = 0x81;
}
void PORT_Init(void)
{
P1MDOUT = 0x1C;//使能P1.2 P1.3 P1.4
XBR1 = 0x40;
}
sbit LED=P1^2 //怎么通过A B C 3个位控制8个LED灯?
;
void main(void)
{
PCA0MD &= ~0x40;
SYSCLK_Init();
PORT_Init();
while(1)
{
Delay();
LED=1;
Delay();
LED=0;
}
}
#define uchar unsigned char
void Delay()
{
uchar a,b;
for(a=0;a<20;a++)
for(b=0;b<20;b++) ;
}
void SYSCLK_Init(void)
{
OSCICN = 0x81;
}
void PORT_Init(void)
{
P1MDOUT = 0x1C;//使能P1.2 P1.3 P1.4
XBR1 = 0x40;
}
sbit LED=P1^2 //怎么通过A B C 3个位控制8个LED灯?
;
void main(void)
{
PCA0MD &= ~0x40;
SYSCLK_Init();
PORT_Init();
while(1)
{
Delay();
LED=1;
Delay();
LED=0;
}
}