Conver RC Reciver Signal To Analog 0-5 Voltage

Hi
I Have a FLY SKY FS-T6 Radio control and I want to use that to drive Motor Dc with arduino Nano.
But I Don't know how I should Read Signal with Aduino and convert it to Analog 0-5.
How I Should Do It?

What motors do you want to control?

Do you have a h-bridge? If so which one?

Here's some code you could use to capture the receiver pulses.

The pulse are used to control two CR servos in the above example. It wouldn't be hard to change the code to control a couple h-bridges.

DuaneDegn:
What motors do you want to control?

Do you have a h-bridge? If so which one?

Here's some code you could use to capture the receiver pulses.

The pulse are used to control two CR servos in the above example. It wouldn't be hard to change the code to control a couple h-bridges.

Yeah, I made it with Relay for high current.
Its Important to me that I read the pulse and convert it to analog. I made the driver.

sadegh_95:
Yeah, I made it with Relay for high current.
Its Important to me that I read the pulse and convert it to analog. I made the driver.

The above statement appears to be contradictory.

What sort of relay are you using? I'm not aware of any relays which use analog input.

Can you post some code on how you would control the motor?

For example, here's some code I recently posted to control two motors using direction pins and PWM of the enable pins.

void motorControl(int robotSpeed, int robotTurn)
{
  int motorPower[2];
  motorPower[PORT_SIDE] = robotSpeed + robotTurn;
  motorPower[STARBOARD_SIDE] = robotSpeed - robotTurn;

  for (int motorIndex = 0; motorIndex < 2; motorIndex++)
  {
    if (motorPower[motorIndex] < 0)
    {
      digitalWrite(DIRECTION_PIN[motorIndex], LOW);
      digitalWrite(BRAKE_PIN[motorIndex], LOW);
      motorPower[motorIndex] *= -1; // make motorPower positive to use with analogWrite
    }
    else if (motorPower[motorIndex] > 0)
    {
      digitalWrite(DIRECTION_PIN[motorIndex], HIGH);
      digitalWrite(BRAKE_PIN[motorIndex], LOW);
    }
    else
    {
      digitalWrite(DIRECTION_PIN[motorIndex], LOW);
      digitalWrite(BRAKE_PIN[motorIndex], DYNAMIC_BRAKE);
    }
    analogWrite(ENABLE_PIN[motorIndex], motorPower[motorIndex]);
  }
}

If you post some example code for controlling your motors, I'll probably try to adapt the code to work with the RC receiver input.

DuaneDegn:
The above statement appears to be contradictory.

What sort of relay are you using? I'm not aware of any relays which use analog input.

Can you post some code on how you would control the motor?

For example, here's some code I recently posted to control two motors using direction pins and PWM of the enable pins.

void motorControl(int robotSpeed, int robotTurn)

{
  int motorPower[2];
  motorPower[PORT_SIDE] = robotSpeed + robotTurn;
  motorPower[STARBOARD_SIDE] = robotSpeed - robotTurn;

for (int motorIndex = 0; motorIndex < 2; motorIndex++)
  {
    if (motorPower[motorIndex] < 0)
    {
      digitalWrite(DIRECTION_PIN[motorIndex], LOW);
      digitalWrite(BRAKE_PIN[motorIndex], LOW);
      motorPower[motorIndex] *= -1; // make motorPower positive to use with analogWrite
    }
    else if (motorPower[motorIndex] > 0)
    {
      digitalWrite(DIRECTION_PIN[motorIndex], HIGH);
      digitalWrite(BRAKE_PIN[motorIndex], LOW);
    }
    else
    {
      digitalWrite(DIRECTION_PIN[motorIndex], LOW);
      digitalWrite(BRAKE_PIN[motorIndex], DYNAMIC_BRAKE);
    }
    analogWrite(ENABLE_PIN[motorIndex], motorPower[motorIndex]);
  }
}




If you post some example code for controlling your motors, I'll probably try to adapt the code to work with the RC receiver input.

I dont want to control speed motor. Just Left or Right Side

sadegh_95:
I dont want to control speed motor. Just Left or Right Side

So how do you turn on the left or right motors?

Don't PM questions.

You can convert Pulses from an rc Receiver to a value between 0 and 1023 with this Code:

int inputpin = 2;                   //Doesn't has to be a pwm
int outputpin = 6;                 //Has to be an analog pin
pinMode(inputpin,INPUT);     //First enable inputpin as Input
pinMode(outputpin,OUTPUT);

And you can read the Signals and convert them to a analog value with:

int readSignal(int pin)
{

    int val = map(pulseIn(pin,HIGH,25000),600,2400,0,1023); // pulse pin, convert range to analog value
    return val;

}

If you are using an rc Receiver with the old Signal range (1000 - 2000)
then you should try this:

int readSignal(int pin)
{

    int val = map(pulseIn(pin,HIGH,25000),1000,2000,0,1023);
    return val;

}

Works for me for questions pm me

I hope this helps you sry for my bad English i'm not a native speaker

florian_markert:
You can convert Pulses from an rc Receiver to a value between 0 and 1023 with this Code:

I know the OP makes it sound like they want an analog output (which is generally 0 to 255), but a relay is an on or off device. I don't understand how the input is supposed to map to relay control.

BTW, pulseIn is an easy way to receive RC inputs. In many applications it should work just fine but pulseIn blocks the code while it waits for the input pulse. If you want to make sure you capture all the incoming pulses, follow the links I left earlier.

DuaneDegn:
So how do you turn on the left or right motors?

Don't PM questions.

Forget control motors, I want something like this picture.

When do you want to turn the leds on and off?
If you want to dim the leds you can use this for a single led:

int receiverpin = 2;
int led = 3;
int time = 0;

void setup() {

  pinMode(receiverpin,INPUT);
  pinMode(led,OUTPUT);
  Serial.begin(9600);

}

void loop() {

  time = pulseIn(receiverpin, HIGH, 25000);
  analogWrite(led,map(time, 600,2400,0,255));
  delay(100);
  
}