RC reciever to analog 0-5 voltage

const int receivePin = 2;  // The pin connected to the RC receiver's servo output
const int outputPin = 3;  // Output PWM pin
unsigned long pulseLength = constrain(pulseIn(receivePin, HIGH), 1000, 2000);
analogWrite(outputPin, map(pulseLength, 1000, 2000, 0, 255));