In this project, we will basic arduino code for espcopter to control espcopter RGB LED.
ESPcopter is currently crowdfunding, with differing reward levels available depending on the expansion boards and quantity desired.
1-) Open the espcopter RemoteXY control code.
2-) Check the standard code
#define REMOTE_XY_OWN
#include "remotexy.h"
#include <espcopter.h> // ESPcopter lib
void setup() {
mainSetup();
}
void loop() {
mainLoop (); // main loop
}
3-) Make a control interface on RemoteXY
Link: http://remotexy.com/en/editor/
4-) Make RemoteXY Settings
4-) Get the RemoteXY Code by click to "Get source code"
5-) Edit the Flying Code by Using SDK
SDK: http://espcopter.com/wp-content/uploads/2016/09/ESPcopter-SDKEnglish.pdf
#define REMOTE_XY_OWN
#include "remotexy.h"
#include <espcopter.h>
// ************************************************************************************************************************************
int controlButton_1 = 0;
int controlButton_2 = 0;
void setup() {
mainSetup();
Trim_Roll = 0; // -1750, 1750
Trim_Pitch = 0; // -1750, 1750
Trim_Yaw = 0; // -1750, 1750
}
void loop() {
mainLoop(); // main flying loop
if(RemoteXY.switch_1 == 1){ // if switch_1 is on do here
armControl =1;
if(RemoteXY.button_2 == 1){
SetPointOpt[1] = -15;
}else if(RemoteXY.button_3 == 1){
SetPointOpt[1] = 15;
}else{
SetPointOpt[1] = 0;
}
if(RemoteXY.button_4 == 1){
SetPointOpt[0] = 15;
}else if(RemoteXY.button_5 == 1){
SetPointOpt[0] = -15;
}else{
SetPointOpt[0] = 0;
}
takeOff(500, 25000); //Take off 500 altitude for 25 seconds
land();//land
}else{ // if switch_1 is off do here
armControl = 0; // close the motors
}
}
remotexy.h//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,5,0,0,0,71,0,8,13,0,
2,0,9,6,29,17,2,26,31,31,
79,78,0,79,70,70,0,1,0,57,
7,21,21,2,31,105,108,101,114,105,
0,1,0,57,38,22,22,2,31,103,
101,114,105,0,1,0,39,25,18,18,
2,31,115,111,108,0,1,0,78,24,
19,19,2,31,115,97,103,0 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t button_2; // =1 if button pressed, else =0
uint8_t button_3; // =1 if button pressed, else =0
uint8_t button_4; // =1 if button pressed, else =0
uint8_t button_5; // =1 if button pressed, else =0
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
Result:
ESPcopter is currently crowdfunding, with differing reward levels available depending on the expansion boards and quantity desired.
Comments