I have a very simple sketch that's supposed to intercept the signal from an RC receiver and print the pulse duration from that channel.
Sketch
int PwmPin = 9;
unsigned long duration;
void setup() {
pinMode(PwmPin, INPUT);
Serial.begin(9600);
}
void loop() {
duration = pulseIn(PwmPin, HIGH);
Serial.println(duration);
}
Output
0
0
0
...
My setup is the normal one that would occur without an Arduino, and only the battery is connected through the ESC to provide power to the receiver. The Arduino is connected via USB because I'm just trying to read values.
I have been trying to plug between the receiver's data pin to the Arduino's PWM pin and read the pulses from the rudder channel. (I have previously tested the channel with a servo and know that it works correctly). However, no signal (0
) is being printed to the serial monitor. I have difficulty understanding why.
I checked the documentation for pulseIn()
, and it seems simple enough. I tested PWM pins D3
, D5
, D10
... none of them works. I don't understand where the problem is at this point. Update: I am now connecting from the receiver's negative pin to one of the Arduino's GND
s.
This is a simplistic scenario, so I don't see what's going wrong (my programming experience is good, but my experience with Arduino is near nil).
The goal of this experiment is to program lights to change according to throttle input, and asymmetric thrust through two motors for a boat. I know that pulseIn isn't the best function to use, but for the moment I just want to do some quick development before getting into the weeds.
Update: I am attempting to follow this video, except that connecting the Arduino to the receiver didn't work, possibly because the ESC's BEC sends some sort of power signal that arms the receiver. (The receiver's LEDs usually make a visual signal, but they just turn on without a signal when connected through the Arduino).
According to the manual on page 6 and page 8, "receivers have an operational voltage range of 3.5 to 9 volts", with an ideal voltage being above 4.8V (because servos tend to brownout sooner). This should fall within Arduino range at 5V.