Mapping PPM Signals to Servo Values This question is an extension of this question.

Accessing Values From Array Within a Library

The answer provided by Mark showed me how to read and print a single value from a particular array by using the index number to print to the serial console.

The second part of this question is how to get these values from the array to map to 0-180 for values that are useful to the servo.

The below code is my attempt that is not working. I used the servo sweep example from the Arduino examples which worked fine with a potentiometer but not with the ppm input. What am I doing wrong here? This won't compile. (I am using TinyServo.h library since this is for an attiny85. Works with with the pot mapping just fine.)

#include &lt;TinyServo.h&gt;
#include &lt;TinyPinChange.h&gt;
#include &lt;TinyPpmReader.h&gt;
#include &lt;Rcul.h&gt;

int PPM_INPUT_PIN = TinyPpmReader.width_us(3); //&lt;------- Doesn't work

//int potpin0 = 3;    &lt;---------          // This worked 
int val0;                     // integer to store value



const byte SERVOS = 1;                   // how many servos do you have? up to 5 on ATTiny85 and 8 on ATtiny84/2313
const byte servoPin[SERVOS] = { 0 }; // what pins are your servos on?
                                       // you have the option to give your servos nice names. 0 refers to the first servo pin above, 1 to the second, etc


#define PANSERVO 0
#define PPM_INPUT_PIN  2    &lt;--------- //define pin for ppm input


void setup()
{
  setupServos();
}


void loop() 
{ 
  val0 = analogRead(PPM_INPUT_PIN);  &lt;---------          //Doesnt work// reads the value of the       potentiometer (value between 0 and 1023)            // reads the value of the 2nd potentiometer (value between 0 and 1023) 
  val0= map(val0, 1000, 2000, 0, 180);
    // scale it to use it with the servo (value between 0 and 180) 
       // scale it to use it with the servo (value between 0 and 180) 

moveServo(PANSERVO, val0);

  delay(5);                           // waits for the servo to get there 
} 


For some background, the ppm library outputs like this to the serial monitor:

Ch4=1560 us

These values move from ~1000 - 2000 depending on the ppm signal input. (The input is from a RC remote control receiver)

This example below prints only channel 4 (Ch4=1560 us)from  a total of 8 channels. Now, I want to map this to the values of 0-180:

#include &lt;TinyPinChange.h&gt;
#include &lt;TinyPpmReader.h&gt;
#include &lt;Rcul.h&gt;

#define PPM_INPUT_PIN  2

void setup()
{
  Serial.begin(38400);//attiny tx - rx uno does not work at 9600 baud. Set to 38400 @ attiny 1mhz and uno serial console to 38400 baud
  TinyPpmReader.attach(PPM_INPUT_PIN); /* Attach TinyPpmReader to PPM_INPUT_PIN pin */
}

void loop()
{

Serial.print(F("Ch"));Serial.print(3);Serial.print(F("="));Serial.print(TinyPpmReader.width_us(3));Serial.println(F(" us")); 


 display results */
  delay(500);
}


What am I doing wrong?
int PPM_INPUT_PIN = TinyPpmReader.width_us(3); 


will save the result into variable PPM_INPUT_PIN, while 

val0 = analogRead(PPM_INPUT_PIN);


will save an analog reading results from PPM_INPUT_PIN channel into variable val0. This is (one of) your problem.
To map the PPM value, you can do:

#include &lt;TinyServo.h&gt;
#include &lt;TinyPinChange.h&gt;
#include &lt;TinyPpmReader.h&gt;
#include &lt;Rcul.h&gt;

int val0,                     // integer to store value
    mappedval0;               // integer to store mapped value;

const byte SERVOS = 1;                   // how many servos do you have? up to 5 on ATTiny85 and 8 on ATtiny84/2313
const byte servoPin[SERVOS] = { 0 }; // what pins are your servos on?
                                       // you have the option to give your servos nice names. 0 refers to the first servo pin above, 1 to the second, etc


#define PANSERVO 0
#define PPM_INPUT_PIN  2    &lt;--------- //define pin for ppm input


const int PPM_max_value = xxxxx; //put the max value of PPM reading result
const int PPM_min_value = yyyyy; //put the min value of PPM reading result


void setup()
{
  setupServos();
}


void loop() 
{ 
  val0 = TinyPpmReader.width_us(4);   //get PPM reading result from index 4
  mappedval0= map(val0, PPM_min_value, PPM_max_value, 0, 180);
    // scale it to use it with the servo (value between 0 and 180) 

  moveServo(PANSERVO, mappedval0);
  delay(5);                           // waits for the servo to get there 
}