Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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); } }
Assigned to
10 years, 5 months ago.This means that the question has been accepted and is being worked on.
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