Hi,
I hacked my old Walkera RX-602 according this tutorial: Walkera_RX-602 - MikrokopterWiki
And It seems that all works fine reading the values from the Channel 1 pins.
The problem I have is that I dont know how to check if radio is OFF because the radio sends raw values.
The sketch is very simple:
#define channNumber 4
int channelValue[channNumber];
int pinRadioRC = 2;
void setup()
{
pinMode(pinRadioRC, INPUT);
}
void loop()
{
readRadio();
currentMillis = millis();
if (currentMillis - startMillis > timer)
{
printRadio();
startMillis = currentMillis;
}
}
void readRadio()
{
if(pulseIn(pinRadioRC, LOW) > 2000)
{
for(int ch = 0; ch < channNumber; ch++)
{
channelValue[ch] = pulseIn(pinRadioRC, LOW);
}
}
}
void printRadio()
{
for(int ch = 0; ch < channNumber; ch++)
{
Serial.print(" Ch");
Serial.print(ch);
Serial.print(": “);
Serial.print(channelValue[ch]);
}
Serial.println(”");
}
Output with Radio ON:
Ch0: 785 Ch1: 906 Ch2: 1107 Ch3: 1069
Ch0: 785 Ch1: 906 Ch2: 1106 Ch3: 1068
Ch0: 784 Ch1: 907 Ch2: 1106 Ch3: 1068
As you can see the values are expected (500 to 1500).
Output with Radio OFF:
Ch0: 737 Ch1: 182 Ch2: 443 Ch3: 24
Ch0: 91 Ch1: 205 Ch2: 541 Ch3: 1247
Ch0: 680 Ch1: 289 Ch2: 144 Ch3: 339
Raw values…
I see options for antiglitch, etc (http://blog.bricogeek.com/noticias/arduino/codigo-como-leer-pulsos-ppm-con-arduino/) but the problem as I said is that I dont know how to detect that the Radio is OFF.
Any help will be very appreciated.