How to solve problems with channels of a remote control?

I have a very big problem, I’m making a puck collect with an arduino mega, and I’m using a remote control of 6 channels. I did my code for motors and it works perfectly, I used 2 channels, but I have to control a servomotor with another channel, and when I put that chanel in my code, one channel doesn’t work. HELP ME PLEASE!!!

CODE:

#include <Servo.h>
#include <AFMotor.h>
#define CH2 2 //Se definen pines para los canales del receptor
#define CH3 10
#define CH4 13

int led1=24;//led metal
int led2=25;//led plastico
Servo servo1;
int est1=22;//sensor 1
int est2=23;//sensor 2

int lect1;
int lect2;
int lect3;
int valor; //variables para la lógica
int valor2;

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

void setup(){

Serial.begin(9600);
pinMode(CH2,INPUT);
pinMode(CH3,INPUT);
pinMode(CH4,INPUT);

pinMode(est1,INPUT);
pinMode(est2,INPUT);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
servo1.attach(9);
servo1.write(0);

// Prender el motor #1
motor1.setSpeed(255);
motor1.run(RELEASE);

// Prender el motor #2
motor2.setSpeed(255);
motor2.run(RELEASE);

// Prender el motor #3
motor3.setSpeed(255);
motor3.run(RELEASE);

// Prender el motor #4
motor4.setSpeed(255);
motor4.run(RELEASE);

}
void loop(){

{valor=pulseIn(CH2,HIGH,4000);
Serial.print("CH2: ");Serial.println(valor);
delay(10);
valor2=pulseIn(CH4,HIGH,4000);
Serial.print("CH4: ");Serial.print(valor2);

/*
motor1 motor3

motor2 motor4
*/
if (valor2>1600)
{
Serial.println(“Giro Derecha”);
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
}

else if(valor>1600)
{
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
Serial.println(“Adelante”);}

else if((valor<1600)&&(valor>1400))
{
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
Serial.println(“Pausa”);}

else if((800<valor) && (1460>valor))
{
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
Serial.println(“Atras”);
}

else if ((valor2<1400)&&(valor2>1000))
{
Serial.println(“Giro Izquierda”);
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);}

else if ((valor2>1400)&&(valor2<1600))
{
Serial.println(“DETENIDO”);
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);}}

lect3=pulseIn(CH3,HIGH,4000);
Serial.print("CH3: ");Serial.println(lect3);
delay(20);

lect1=digitalRead(est1);
lect2=digitalRead(est2);
if(lect3>1000&&lect3<1480){
servo1.write(90);
if(lect1==0||lect2==0){
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW); }
if(lect1==1&&lect2==1){
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH); } }
else{
if(lect3<1000){
servo1.write(0);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);}}

}

I'm making a puck collect

What is that?

and when I put that chanel in my code, one channel doesn't work. HELP ME PLEASE!!!

I'm not going to post my code properly. I'm not going to tell you which channel quits working. I'm not going to tell you what the code actually does. I'm not going to tell you how that differs from what I actually want. I am going to scream at you. I am going to use excessive punctuation.

I wonder why you are getting flooded with responses.

Have a look at the reference page for the Servo object and its effect on PWM

I'm making a puck collect

Does Oberon know?

Using pulsein and the servo lib do not work well together. I think they use the same timer? I have used the servo pro IC which uses I2C for coms and handles everything to do with controlling your servos. This will then allow you to use pulsein to read the Rx signals.

But then I have ran into another problem that when using pulsein on multiple (6 for me) channels it can slow the code down a fair bit - around 350ms per loop. So now I am trying (not very successful yet) to use the pin change interrupt method of reading Rx PWM signals.

If you are not to worried about speed or not reading many channels then the servo pro is a great little chip that will allow you to use pulsein.