I have a Electronic Speed Controller (ESC) being controlled with Pulse Width Modulation (PWM) from an Arduino.
When I put my hand close to the cables the signal goes screwy until I move my hands away. I checked for shorts but didn't find any. I don't have an oscilloscope or that would give me my answer.
What's happening here?
I also made this video to help explain the situation.
Rough Schematic
EDIT
Adding working Arduino code for future visitors
#include <SoftwareServo.h> // Download from http://playground.arduino.cc/ComponentLib/Servo
SoftwareServo myservo; // create servo object to control a servo
//int potpin = 0; // analog pin used to connect the potentiometer
int PIN = 2;
int val; // variable to read the value from the analog pin
void setup()
{
Serial.begin(115200);
myservo.attach(PIN); // attaches the servo on pin 2 to the servo object
}
void loop()
{
char r = Serial.read();
String inStr = String(r);
if(r > -1) {
Serial.print("serial in: ");
Serial.println(inStr);
}
if(r <= -1) {
// void
} else if(inStr == "h") { // high
Serial.println("HIGH");
digitalWrite(PIN, HIGH);
} else if(inStr == "m") { // medium
Serial.println("medium");
myservo.write(90);
} else if (inStr == "l") { // low
Serial.println("LOW");
digitalWrite(PIN, LOW);
} else if (inStr.toInt() >= 0 && inStr.toInt() <= 9) {
int val = inStr.toInt() * 20;
Serial.println(val);
myservo.write(val);
}
// float t = millis() / 100;
// val = sin(t / 10) * 1000;//analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
// // if(val < 0) val *= -1;
// val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
// val = millis() / 100;
// myservo.write(val); // sets the servo position according to the scaled value
// Serial.println(val);
// delay(15); // waits for the servo to get there
SoftwareServo::refresh();
}