PIC单片机控制继电器原理及实现
扫描二维码
随时随地手机看文章
#include
#define uchar unsigned char
#define uint unsigned int
__CONFIG(0x3B31);
void delay(uint x);
void main()
{
TRISE1=0;
TRISB=0x0f;
RE1=0;
while(1)
{
if(RB0==0)
{
delay(10);
if(RB0==0)
{
while(!RB0);
RE1=1;
}
}
if(RB1==0)
{
delay(10);
if(RB1==0)
{
while(!RB1);
RE1=0;
}
}
}
}
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--);
}