CoDrone Coding Killswitch?

  • Hi my name is Johnny Acevedo and I am a STEM Educator in Harlem NYC.

    I am a CoDrone noob and have been working through the lessons as I anticipate teaching with CoDrone to a group of 20 students each with their own drones.

    When I was attempting Pin Point Challenge in Beginner's Lesson 4 my CoDrone moves up (throttles) when Pitching until it reaches the ceiling and gets stuck hovering there.

    I have isolated the throttle code and CoDrone should only be moving down but it does not.

    Two questions:

    1. Why does CoDrone fail to throttle down when?
    2. Is there a way to code a kill switch on the controller so that CoDrone can be stopped immediately when it gets stuck somewhere or might hit someone?

    Here is the code I am using so far:

    #include <CoDrone.h>
    void setup() {
      CoDrone.begin(115200);          //Intitialize Connection with Specific CoDrone
      byte droneAddress[6]= {0xB4, 0x2D, 0xBC, 0xC2, 0xB5, 0xD0};
      CoDrone.AutoConnect(AddressInputDrone, droneAddress);
      CoDrone.FlightEvent(TakeOff);   //TakeOff for 2 seconds
     // PITCH=30;                       //Pitch+(forward) 
      //THROTTLE=-20;                    //Throttle-(Down) for 1 seconds
      //YAW=-90;                         //Yaw-(Rotate CCW left) for 2 seconds
      //PITCH=70;                       //Pitch+(forward) 
      CoDrone.FlightEvent(Landing);   //Land
    void loop() {
      // put your main code here, to run repeatedly:

  • Hi there @johnnytechknow! You're currently on the phone with @arnold_robolink, but I wanted to link you to the lesson that includes a killswitch in the loop() function. But as he said, when the drone goes up to the ceiling, what's happening is a suction force that keeps it stuck on the ceiling. Throttling down won't be strong enough to make it descend in this case, so having a killswitch is always key. You'll need to put the killswitch in the loop() function of your Arduino code, so that it's constantly checking for input.

    I'll post the code here, and also link you to the lesson on Basecamp.

    void loop () {
        /* Start of the kill switch*/
        byte bt8 = digitalRead(18);
        byte bt4 = digitalRead(14);
        byte bt1 = digitalRead(11);
        if(bt1 && bt4 && !bt8){
        /*end of kill switch*/

    @arnold_robolink if there's anything I've missed, please supplement with anything else.

Log in to reply

Looks like your connection to Robolink community was lost, please wait while we try to reconnect.