PPM信号怎么处理?(遥控器音频教练口控制arduino)
本帖最后由 O_o 于 2013-3-18 13:14 编辑变成无限累加 时间了要控制 必须 记录每个通道的时间。
每通道信号间隔260μm 20ms 更新一次
int PPM = 2;
unsigned longasshoeltime;
unsigned longasshoeltime2;
void setup()
{
Serial.begin(9600);
pinMode(PPM, INPUT);
attachInterrupt(0, fuck1, RISING);
attachInterrupt(0, fuck2, FALLING);
}
void fuck1()
{
asshoeltime = micros();
}
void fuck2()
{
asshoeltime2 = micros() - asshoeltime;
}
void loop() {
Serial.print("");
Serial.print(asshoeltime2);
} 感谢 http://www.geek-workshop.com/thread-2408-1-1.html
感谢群里面的各位
int PPM = 2;
unsigned longasshoeltime;
unsigned longasshoeltime2;
int ass =0;
int C1=0;
int C2=0;
int C3=0;
int C4=0;
int C5=0;
int C6=0;
void setup()
{
Serial.begin(9600);
pinMode(PPM, INPUT);
attachInterrupt(0, fuck, CHANGE);
}
void fuck() {
if (digitalRead(PPM) == HIGH)
asshoeltime = micros();
else{
asshoeltime2 = micros() - asshoeltime;
ass=++ass;
if (ass==8){
ass=1;
}
if (asshoeltime2>3000){
ass=7;
}
if (ass==1){
C1=asshoeltime2;
}
if (ass==2){
C2=asshoeltime2;
}
if (ass==3){
C3=asshoeltime2;
}
if (ass==4){
C4=asshoeltime2;
}
if (ass==5){
C5=asshoeltime2;
}
if (ass==6){
C6=asshoeltime2;
}
}
}
void loop() {
Serial.print(C1);
Serial.print(" ");
Serial.print(C2);
Serial.print(" ");
Serial.print(C3);
Serial.print(" ");
Serial.print(C4);
Serial.print(" ");
Serial.print(C5);
Serial.print(" ");
Serial.print(C6);
Serial.println(" ");
delay(100);
} 楼主这个用的什么示波器?
页:
[1]