标题:
PIC10F202做的一个按键切换两个继电器
[打印本页]
作者:
gravedigger
时间:
2018-2-19 00:17
标题:
PIC10F202做的一个按键切换两个继电器
环境X IDE V2.35
C
PICKIT3
一个按键切换两个继电器单片机源程序如下:
#include<pic.h>
#include <xc.h>
#pragma config WDTE = OFF // Watchdog Timer (WDT disabled)
#pragma config CP = OFF // Code Protect (Code protection off)
#pragma config MCLRE = OFF // Master Clear Enable (GP3/MCLR pin fuction is digital I/O, MCLR internally tied to VDD)
void DELAY(unsigned int n)
{
unsigned int j;
unsigned int k;
for(j=0;j<n;j++)
for(k=200;k>0;k--)
NOP();
}
void main()
{
GP0=GP1=GP2=0;
unsigned char num=0;
TRISGPIO=0b00001000;
OPTION=0B010000111;
OSCCAL=0b11111110;
while(1)
{
if(GP3==0)
{
DELAY(20);
if(GP3==0)
{
while(!GP3);
num++;
}
}
if(num==3)
{
num=0;
GP1=GP2=0;
}
if(num==1)
{
GP1=1;GP2=0;
}
if(num==2)
{
GP1=0;GP2=1;
}
}
}
复制代码
所有资料51hei提供下载:
一个按键切换两个继电器.rar
(567 Bytes, 下载次数: 43)
2018-2-19 00:15 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
xianrui1989
时间:
2018-9-18 17:23
谢谢论坛,正在找关于F202的程序
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1