Go Down

Topic: Arduino pulseIn returns weird values (Read 365 times) previous topic - next topic

kschembri

Hi guys, brand new to arduino! So far I am loving the platform.

I'm trying to connect my arduino board to my RC receiver. I have the receiver powered using a pretty standard 4xAA pack, and I have one channel of the receiver connected to pin 7 on the arduino (I've tried several different pins for this).

My problem: The code below just returns numbers in the range of 8000 (sometimes 9000 and sometimes 7000), and this doesn't change when I apply the controllers joystick. What's weirder is that the numbers return even when the wire to pin 7 is unplugged from the receiver (but still attached to the arduino). Does this make sense? Any thoughts?

Code: [Select]
int pin = 7;
unsigned long duration;

void setup()
{
  pinMode(pin, INPUT);
  Serial.begin(9600); // Pour a bowl of Serial
}

void loop()
{
  duration = pulseIn(pin, LOW);
  Serial.print("Channel 1:"); // Print the value of
  Serial.println(duration);        // each channel
}

Grumpy_Mike

Quote
and I have one channel of the receiver connected to pin 7 on the arduino

And have you connected the ground of your receiver to the ground of the arduino?

kschembri

#2
Dec 22, 2013, 06:33 pm Last Edit: Dec 22, 2013, 06:49 pm by kschembri Reason: 1
No the ground is connected to the ground of the battery pack. Would that be the issue? Actually, the receiver doesn't have a ground - it's just +/-/signal? Would - be the ground?


Grumpy_Mike

For future reference this is why you need a common ground when connecting other equipment:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

Go Up