void loop(){
//循环打印通道值,取1-8的值
for (byte i = 0; i < CHANNEL_AMOUNT + 1; i++){
Serial.print(ch[i]);
Serial.print("\t");
;
}
Serial.println("");
bnew=(90+(1500-ch[1])/5);//500:90的系数
anew=(90+(1500-ch[2])/5);
bservo.write(bnew);
aservo.write(anew);
}
ICACHE_RAM_ATTR void ppm_interrupt(){
static byte i;
static unsigned long int t_old;
unsigned long int t = micros(); //储存时间值t当引脚值下降/上升时
unsigned long int dt = t - t_old; //计算两个峰之间的时间
t_old = t;
if ((dt > DETECTION_SPACE) || (i > CHANNEL_AMOUNT)){
i = 0;
}
ch[i++] = dt;
}