Close

Making an ESPcopter Altitude Indicator

A project log for Programing ESPcopter - ESP8266 Drone with Visuino

Visually Programing ESPcopter - ESP8266 based programmable Drone with Visuino

metehanemlikmetehanemlik 08/14/2019 at 14:580 Comments

In this project, we will make an altitude Indicator using a NeoPixel shield. NeoPixel LEDs will turn on according drone altitude up to the 1 meter. The first four LEDs will be light green, second four LEDs light blue, and third four red.

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 control code

#define REMOTEXY_WIFI_SSID "ESPcopter" //ESPcopter Wiffi name
#define REMOTEXY_WIFI_PASSWORD "12345678" //ESPcopter Wiffi pass  

#define REMOTE_XY_REMOTE // control method  

#include <espcopter.h> // ESPcopter lib  

void setup() { mainSetup(); // main settings 
setTrimRoll(0);
setTrimPitch(0);
setTrimYaw(0);
}

void loop() { 
mainLoop ();  // main loop
}

3.) Edit the flying code by using SDK

3.) Edit the flying code by using SDK

SDK: http://espcopter.com/wp-content/uploads/2016/09/ESPcopter-SDKEnglish.pdf

We will use NeoPixel commands and altitude hold commands.

NeoPixel control code:

 int altitudeDrone = constrain(round(getOtoMeasure()/45),0,12); //  get drone alttitude and convert it milimeter to integer 0-12 
     
  for(int i =0; i < altitudeDrone; i++){// for loop for switching the leds on
    if(i < 4){ // if altitude of drone is lower than 40cm 
    ESPsetPixel(i,0,255,0); // on green 0-4
    }
    if(i >= 4 && i < 8 ){ // if altitude of drone  is between 40cm and 80cm 
    ESPsetPixel(i,0,0,255); // on blue 4-8
    }
    if(i >= 8 && i < 12){ // if altitude of droneis between 80cm and 120cm 
    ESPsetPixel(i,255,0,0); // on red 8-12
    }
  }
  for(int i =11; altitudeDrone < i; i--){ // for loop  for switching the leds off
    ESPsetPixel(i,0,0,0);
  }
  ESPpixelShow(); // commint
#define REMOTEXY_WIFI_SSID "ESPcopter" //ESPcopter Wiffi name
#define REMOTEXY_WIFI_PASSWORD "12345678" //ESPcopter Wiffi pass
  
#define REMOTE_XY_REMOTE // control method 
  
#include <espcopter.h> // ESPcopter lib
  
void setup() {
 mainSetup(); // main settings
 setTrimRoll(0);
 setTrimPitch(0);
 setTrimYaw(0);
}
void loop() {
  mainLoop ();  // main loop
  
for(int i =0; i < altitudeDrone; i++){// for loop for switching the leds on
   if(i < 4){ // if altitude of drone is lower than 40cm 
   ESPsetPixel(i,0,255,0); // on green 0-4
   }
   if(i >= 4 && i < 8 ){ // if altitude of drone  is between 40cm and 80cm 
   ESPsetPixel(i,0,0,255); // on blue 4-8
   }
   if(i >= 8 && i < 12){ // if altitude of droneis between 80cm and 120cm 
   ESPsetPixel(i,255,0,0); // on red 8-12
   }
 }
 for(int i =11; altitudeDrone < i; i--){ // for loop  for switching the leds off
   ESPsetPixel(i,0,0,0);
 }
 ESPpixelShow(); // commint*/
  
}


Result:

Discussions