標(biāo)題:
51單片機(jī)實(shí)例
[打印本頁(yè)]
作者:
KX1649464501
時(shí)間:
2021-6-24 11:35
標(biāo)題:
51單片機(jī)實(shí)例
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit K1 = P1^0;
sbit RELAY = P2^4;
void DelayMS(uint ms)
{
uchar t;
while(ms--)
{
for(t=0;t<120;t++);
}
}
void main()
{
P1 = 0xff;
RELAY = 1;
while(1)
{
if(K1==0)
{
while(K1==0);
RELAY = ~RELAY;
DelayMS(20);
}
}
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1