|
最近新買了一個搖桿模塊,看它的樣子像是兩個電位器的組合,我編了一個簡單的程序,可是怎么搖都沒反應(yīng)
#include"reg52.h"
sbit x=P2^0;
sbit y=P2^1;
sbit z=P2^2;//搖桿三軸引腳
sbit a=P1^0;
sbit b=P1^1;
sbit c=P1^2;
sbit d=P1^3;//四個led燈abcd
void main()
{
a=b=c=d=1;
while(1)
{
if(y==1&&x==0) a=0;
if(y==1&&x==1) b=0;
if(y==0&&x==0) c=0;
if(y==0&&x==1) d=0;
}
}
|
|