|
Hi people.
OK. John's code works good the only problem is that if I move the RC transmitter stick from full right to full left I get about two seconds respond time. anyone knows how to improve that?
the code:
const int inputPinA = 2; // The pin connected to the RC receiver's servo output A const int outputPinA = 3; // Output PWM pin A const int inputPinB = 4; // The pin connected to the RC receiver's servo output B const int outputPinB = 5; // Output PWM pin B
void setup() { pinMode(inputPinA, INPUT); pinMode(inputPinB, INPUT); }
void loop() { unsigned long pulseLength;
pulseLength = constrain(pulseIn(inputPinA, HIGH), 1000, 2000); analogWrite(outputPinA, map(pulseLength, 1000, 2000, 0, 255));
pulseLength = constrain(pulseIn(inputPinB, HIGH), 1000, 2000); analogWrite(outputPinB, map(pulseLength, 1000, 2000, 0, 255)); }
|