Pages: [1]   Go Down
Author Topic: Arduino pulseIn returns weird values  (Read 282 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33371
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: December 22, 2013, 12:49:18 pm by kschembri » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works! Thank you smiley
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33371
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: