Arduino, Vex receiver and signal splitter

The Arduino powers the vex signal splitter via 5v which in turn powers the vex receiver, no other external power required!

/*
nikitanicholas@gmail.com
Use freely

Vex transmitter & Vex receiver kit : http://www.vexrobotics.com/vex-robotics-transmitter-receiver-add-on-kit.shtml
Vex signal splitter : http://www.vexrobotics.com/vex-robotics-signal-splitter.shtml

5 volts is sent from the arduino to the signal splitter via the positive output of one the the channel connection. The signal splitte ground connection is connected to the arduino ground.
The 5 volts also flows to the receiver - splitter connection.

Vex Properties via the signal splitter
Channel 1,2,3 & 4
range : from  753  to 2241
Center stick position  varies between 1480 and 1510

Channel 5 & 6 (digital Channels)
range : off = 753  on =  2241
not activated:  1500

The Setup
The Arduino powers the vex decoder via 5v which in turn powers the vex receiver, no other external power required.


*/
#define channelNumber 6 // 6 Channels on the vex

int value[channelNumber];
int val;
int adrinoPin;
void setup()
{
  Serial.println("init");
  Serial.begin(57600); //Serial Begin
  pinMode(2, INPUT); //Pin 2 as input
  pinMode(3, INPUT); //Pin 3 as input
  pinMode(4, INPUT); //Pin 4 as input
  pinMode(5, INPUT); //Pin 5 as input
  pinMode(6, INPUT); //Pin 6 as input
  pinMode(7, INPUT); //Pin 7 as input


}
void loop()
{
  adrinoPin = 2;  //  start with pin 2
  Serial.println("looping......");

for(int x=0; x<=channelNumber-1; x++)//Loop to print the channel readings
{
   if (pulseIn(adrinoPin, HIGH)  == 0 )
   {
     Serial.print("No signal on Channel" );
     Serial.print(" ");
     Serial.print(adrinoPin -1); //Print channel
     Serial.println("");
   }
   else
   {
     Serial.print("Channel" );
     Serial.print(" ");
     Serial.print(adrinoPin -1); //Print out the channel number
     Serial.print(" = ");
     //val = .pulseIn(adrinoPin, HIGH);
     val = normalizedPPM(pulseIn(adrinoPin, HIGH));
     Serial.print(val); //Print out the value
     Serial.print(" ");
   }
   value[x]=0; //Clear the array after printing
   adrinoPin++;  // increment pin count
   
   /*                 Future Project
    * Output PWM voltage based on Vex signal pulsein 
    *  The pins marked PWM (pins 3, 5, 6, 9, 10, and 11) can be pulsed using the analogOut() 
    *  Pulsewidth is a value from 0 - 255. 0 corresponds to 0 volts, and 255 corresponds to ~5 volts. 
    *  Every change of one point changes the pseudo-analog output voltage by 5/255, or  0.0196 volts.
    
     When no signal is received from the Vex transmitter or stick prosition are centered
     the following should occur : arduino output 50% duty cycle  corresponding to approx. 2.5v ( PWM to output pin is 127)
     
     When Pulsein is between 1550 and 2200  
     the following should occur : arduino output 75% duty cycle  corresponding to approx. 3.5v (PWM to output pin is 178)
     
     When Pulsein is between 750 and 1450  
     the following should occur  : arduino output 25% duty cycle  corresponding to approx. 1.5v (PWM to output pin is 76)
     
     Available pins  9, 10 , 11
   */
   
   
}
 
 Serial.println("");

 delay(500);

}

/*
 Smoothing out the center channel ( software trimming)
*/
int normalizedPPM(int ppm)
{
   if ( ppm > 1480 && ppm < 1510)
    return 1500;
    else
    return ppm;

}