I am trying to connect my Arduino Micro to my Turnigy 9X receiver without success. The Arduino doesn't react at all on the signal.
I have connected the signal cable from Ch6 on the receiver to Pin 2 on my Arduino. Then I tried using interrupts, like this:
// Never changes, constants
const int quadPin = 2;
void setup()
{
Serial.begin(9600); // setup serial
pinMode(quadPin, INPUT);
attachInterrupt(0, ch2Changed, CHANGE); // Attach interupt on digital channel 2. Calls ch2Changed
}
void loop()
{
//Serial.println("Something");
delay(100);
}
void ch2Changed()
{
if(digitalRead(quadPin) == HIGH)
{
Serial.println("Pin is HIGH!");
}
else
{
Serial.println("Pin is LOW!");
}
}
When running this and flicking the switch on my Turnigy 9X nothing happens. It never registers any changes.
Why could this be?
I measured the signal from Ch6 and when the switch on my controller is OFF it's at ~.2V and when it's ON it's at ~.35V. Is that too low? Or can I even measure like this at all? I guess it's a PPM signal that comes from the receiver...
I guess it's a PPM signal that comes from the receiver...
The output from the receiver pin is a PWM signal. Each receiver channel forms part of a PPM data stream. The position of the data in the stream allows the receiver to distinguish between the channels. Note that each channel is a PWM signal even if the transmitter control is an on/off switch, such as gear up/down, rather than one that is proportional to the movement of a control stick or slider.
I see that you have got the signal decoding working using pulseIn. When I was experimenting with reading an RC signal with the Arduino I used this simple program to investigate the values being output by the receiver.
AWOL:
DuaneB has some useful resources on this subject.
Yes, I believe I linked to his blog in a post above. He uses interrupts. I wonder why my interrupts never fired...
Perhaps my signal is HIGH all the time. When I used pulseIn() I get 1050 when the switch is off and 1880 when it's on. So maybe that change doesn't trigger the interrupt?
When I used pulseIn() I get 1050 when the switch is off and 1880 when it's on. So maybe that change doesn't trigger the interrupt?
Those values are pulse lengths not voltages. The voltage will be varying between 0 and 5V so the interrupt should trigger on every change. Can you try the interrupt with RISING or FALLING ?