|
楼主 |
发表于 2015-7-8 08:37:35
|
显示全部楼层
楼主已经看传一切了,只需在代码中加入这几句就ok了:
int FIRE = 2;//电磁炮火控,喇叭
int POWER = 11;//电磁炮电源,大灯
#define FIRE_high {digitalWrite(FIRE,HIGH);} //发射,喇叭响
#define FIRE_low {digitalWrite(FIRE,LOW);} //发射触发开关关闭,喇叭停
#define POWER_on {digitalWrite(POWER,HIGH);} //电磁炮供电,车灯开
#define POWER_off {digitalWrite(POWER,LOW);} //电磁炮断电,车灯关
pinMode(FIRE,OUTPUT);
pinMode(POWER,OUTPUT);
else if(buffer[0]==0x04)//电磁炮控制,喇叭
{
switch(buffer[1]) //发射/填装,喇叭
{
case 0x00:FIRE_high; return;
case 0x01:FIRE_low; return;
default: return;
}
}
else if(buffer[0]==0x05)//电磁炮电源开关,车灯
{
switch(buffer[1]) //充电/断电,车灯
{
case 0x00:POWER_on; return;
case 0x01:POWER_off;return;
default: return;
}
} |
|