Doing a little project for work and trying to get the Arduino hooked to an RC car to read the throttle channel output and send that via bluetooth to a nearby laptop which will output an animation based on that speed.
Initial test worked very well and signals from my airplane Tx were solid with very little variance. Once the proof of concept worked, we went ahead and purchased a Traxxas car. I have a wire going from pin 5 to the signal wire on the Rx. With the serial monitor up and arduino powered via my usb cable, the #s jump from the 1400 (where its supposed to be) to 6000 and sometimes 11000. Even more interesting, is when I engaged the throttle via the transmitter, values went down to 30-50...?? I removed the Rx from the car and powered it via the 5v on arduino...#s are solid.
So, it appears the battery or esc is giving a lot of interference. Do I need to use a different kind of wire? Or ground it somehow?
int ch1; // Here's where we'll keep our channel values
int ledPin = 11;
void setup() {
pinMode(5, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of the channel
//Serial.print("Channel 1:"); // Print the value of
Serial.println(ch1); // each channel
ch1 = constrain(ch1, 1120, 1900);
int brightness = map(ch1, 1120, 1900, 0, 255);
analogWrite(ledPin, brightness);
delay(250);
}