将代码修改如下,解决问题:
unsigned char DianYa[5]={0xB5,0xE7,0xD1,0xB9,0x3A};
unsigned char DianYaZhi[4]={0x32,0x2E,0x35,0x38};
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
unsigned char temp[sizeof(DianYa)+sizeof(DianYaZhi)];
PinJieZhiFuChuan(DianYa,sizeof(DianYa),DianYaZhi,sizeof(DianYaZhi),temp);
digitalWrite(13,HIGH);
Serial.write(temp,sizeof(temp));
digitalWrite(13,LOW);
delay(1000);
}
//拼接数组
void PinJieZhiFuChuan(unsigned char c1[],int a,unsigned char c2[],int b,unsigned char csum[])
{
a=sizeof(c1);
b=sizeof(c2);
int c=a+b;
int i;
for(i=0;i<c;i++)
{
if(i<a)
{
csum[i]=c1[i];
}
else
{
csum[i]=c2[i-a];
}
}
return;
} |