//按Key3控制 P1^6灯的开和关
//新建工程,添加TouchKey.C,Debug.C两个文件
#include "..\Public\CH554.H"
#include "..\Public\Debug.H"
#include "TouchKey.H"
//#include "stdio.h"
//#pragma NOAREGS
sbit Led = P1^6;
main( )
{
UINT8 i;
CfgFsys( );
mDelaymS(5);
P1_MOD_OC=P1_MOD_OC | (1<<6); //设置P1^6为弱上拉
P1_DIR_PU=P1_MOD_OC | (1<<6);
P1_DIR_PU &= 0x00;
TouchKeyQueryCyl2ms();
GetTouchKeyFree();
Led = 0;
mDelaymS(100);
Led = ~Led;
while(1)
{
TouchKeyChannelQuery();
if(KeyBuf)
{
if(KeyBuf==3) Led = ~Led;
KeyBuf = 0;
}
mDelaymS(100);
}
}
此内容由EEWORLD论坛网友吴下阿蒙原创,如需转载或用于商业用途需征得作者同意并注明出处
|