You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
14 years ago
|
/*
|
||
|
Example of APM_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)
|
||
|
*/
|
||
|
|
||
13 years ago
|
#include <Arduino_Mega_ISR_Registry.h>
|
||
14 years ago
|
#include <APM_RC.h> // ArduPilot Mega RC Library
|
||
|
|
||
13 years ago
|
Arduino_Mega_ISR_Registry isr_registry;
|
||
13 years ago
|
APM_RC_APM2 APM_RC;
|
||
13 years ago
|
|
||
14 years ago
|
void setup()
|
||
|
{
|
||
13 years ago
|
isr_registry.init();
|
||
|
APM_RC.Init(&isr_registry); // APM Radio initialization
|
||
14 years ago
|
|
||
13 years ago
|
APM_RC.enable_out(CH_1);
|
||
|
APM_RC.enable_out(CH_2);
|
||
|
APM_RC.enable_out(CH_3);
|
||
|
APM_RC.enable_out(CH_4);
|
||
|
APM_RC.enable_out(CH_5);
|
||
|
APM_RC.enable_out(CH_6);
|
||
|
APM_RC.enable_out(CH_7);
|
||
|
APM_RC.enable_out(CH_8);
|
||
|
|
||
13 years ago
|
Serial.begin(115200);
|
||
14 years ago
|
Serial.println("ArduPilot Mega RC library test");
|
||
|
delay(1000);
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
// New radio frame? (we could use also if((millis()- timer) > 20)
|
||
|
if (APM_RC.GetState() == 1){
|
||
|
Serial.print("CH:");
|
||
|
for(int i = 0; i < 8; i++){
|
||
|
Serial.print(APM_RC.InputCh(i)); // Print channel values
|
||
|
Serial.print(",");
|
||
|
APM_RC.OutputCh(i, APM_RC.InputCh(i)); // Copy input to Servos
|
||
|
}
|
||
|
Serial.println();
|
||
|
}
|
||
13 years ago
|
}
|