From 6eb2dc13018b82be73b2dfaeee7db9ca6b11cb88 Mon Sep 17 00:00:00 2001 From: jasonshort Date: Mon, 23 Aug 2010 21:29:43 +0000 Subject: [PATCH] Ardupilot Hardware RC Library for the 328 git-svn-id: https://arducopter.googlecode.com/svn/trunk@278 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- .../APM_RC/examples/APM_radio/AP_radio.pde | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 libraries/APM_RC/examples/APM_radio/AP_radio.pde diff --git a/libraries/APM_RC/examples/APM_radio/AP_radio.pde b/libraries/APM_RC/examples/APM_radio/AP_radio.pde new file mode 100644 index 0000000000..0c0cd5a88e --- /dev/null +++ b/libraries/APM_RC/examples/APM_radio/AP_radio.pde @@ -0,0 +1,48 @@ +/* + Example of AP_RC library. + Code by Jordi MuĂ’oz and Jose Julio. DIYDrones.com + + Print Input values and send Output to the servos + (Works with last PPM_encoder firmware) +*/ + +#include // ArduPilot Mega RC Library +AP_RC rc; + +#define CH_ROLL 0 +#define CH_PITCH 1 +#define CH_THROTTLE 2 +#define CH_RUDDER 3 + +void setup() +{ + Serial.begin(38400); + Serial.println("ArduPilot RC library test"); + + int trims[] = {1500,1500,1200,1500}; + rc.init(trims); + + delay(1000); +} +void loop() +{ + delay(20); + rc.read_pwm(); + for(int y=0; y<4; y++) { + rc.set_ch_pwm(y, rc.input[y]); // send to Servos + } + print_pwm(); +} + + +void print_pwm() +{ + Serial.print("ch1 "); + Serial.print(rc.input[CH_ROLL],DEC); + Serial.print("\tch2: "); + Serial.print(rc.input[CH_PITCH],DEC); + Serial.print("\tch3 :"); + Serial.print(rc.input[CH_THROTTLE],DEC); + Serial.print("\tch4 :"); + Serial.println(rc.input[CH_RUDDER],DEC); +} \ No newline at end of file