10 years, 5 months ago.

Can't read analog values from an RC aircraft radio receiver

Hey friends, this is Metin.

I'm trying to write a code that reads analog values from a receiver and directly writes them to the servos of the aircraft but I couldn't even read analog values. All I read(I'm debugging with Teraterm) is 0.000000.

Receiver output is between 2.3V and 4.6V. I'm using Seeduino Arch Pro. Receiver and board works properly. My code is down below. Please take a look.

Regards

#include "mbed.h"

int main()
{
    while(true)
    {
        Serial pc(USBTX, USBRX);
        AnalogIn aileron(P0_23);
        PwmOut aServo(P2_2);
        float temporary = 0.0;
        
        temporary = aileron.read();
        aServo.write(temporary);
        
        pc.printf("Aileron: ");
        pc.printf("%f\r\n", &temporary);
       
        wait(1);
    }
}

First of all, you can place the Serial, AnalogIn, PwmOut and float declarations outside the main() function. Secondly, pc.printf("%f\r\n", &temporary); does not print the value of the temporary variable but the address of this variable, so you need to remove the &.

posted by Frank Vannieuwkerke 07 Jun 2014
Be the first to answer this question.

Assigned to Metin Oktay YILMAZ 10 years, 5 months ago.

This means that the question has been accepted and is being worked on.