Navigation

    Robolink logo
    • Register
    • Login
    • Search
    • [[global:header.categories]]
    • [[global:header.recent]]
    • [[global:header.tags]]
    • [[global:header.popular]]
    • [[global:header.users]]
    • [[global:header.groups]]
    As of September 2021, we have moved technical support to Robolink Help

    Welcome to the Robolink Community forum!

    You can post here to interact with others in the Robolink community. We're checking it weekly, and we'll respond to some messages. If you're looking for technical support, head over to Robolink Help.

    SOLVED Analog Flight Control - Lesson and Video Parity?

    Educators Corner
    3
    3
    4740
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      johnnytechknow last edited by

      I was trying the analog control lesson and followed the example given in the lesson but my CoDrone would not respond to the movement of the analog joysticks. Since you have sent me video links to help fill in gaps of information and understanding for my previous questions I searched and found a video about flight control on the Robolink YouTube channel. This leaves me feeling as an educator that the analog flight control lesson does not provide enough information on its own.

      The code sample in the lesson does not match the Controller Flight code example. Should the code sample from the lesson work? It did not work for me but the example code did.

      Am I missing something?

      I hesitate asking my students to follow a lesson that will leave them unnecessarily frustrated.

      1 Reply Last reply Reply Quote 0
      • Loui2
        Loui2 last edited by Loui2

        Hello, the final code located on this lesson Lesson 2K works in my experience. I tested it out via copy & paste with the only addition I made being a kill switch. Although I'm not sure if this is the lesson you were referring to.

        The code on the lesson is as follows:

        #include <CoDrone.h>
        
        void setup() {
            CoDrone.begin(115200);
            CoDrone.AutoConnect(NearbyDrone);
        }
        
        void loop() {if (PAIRING == true){  
            YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
            THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
            ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
            PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
            CoDrone.Control();   
            }
        }
        

        I highly suggest adding a kill switch or a landing event to the code before flying or else you may not be able to stop the drone from flying.
        Note: The kill switch makes the drone completely stop in the air. I suggest using it when the drone is near the floor or in the case that you need to make an emergency stop (like if it's about to hit someone).

        Here is the exact code I used to test (kill switch added):

        #include <CoDrone.h>
        
        void setup() {
            CoDrone.begin(115200);
            CoDrone.AutoConnect(NearbyDrone);
        }
        
        void loop() {if (PAIRING == true){  
            YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
            THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
            ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
            PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
            CoDrone.Control();   
            }
        
            if(digitalRead(11) && !digitalRead(14) && !digitalRead(18)) //bottom left sensor
            {
              CoDrone.FlightEvent(Stop); // Kill switch
              //CoDrone.FlightEvent(Landing); // Landing event
              CoDrone.Buzz(4000, 7);
              delay(100);
            }
        }
        

        Hope it helps!

        1 Reply Last reply Reply Quote 3
        • robolink_wes
          robolink_wes last edited by

          Thanks so much for your detailed response, @Loui2! @robolink_arnold mentioned your responses are all excellent.

          1 Reply Last reply Reply Quote 0
          • Loui2
            Loui2 last edited by Loui2

            Hello, the final code located on this lesson Lesson 2K works in my experience. I tested it out via copy & paste with the only addition I made being a kill switch. Although I'm not sure if this is the lesson you were referring to.

            The code on the lesson is as follows:

            #include <CoDrone.h>
            
            void setup() {
                CoDrone.begin(115200);
                CoDrone.AutoConnect(NearbyDrone);
            }
            
            void loop() {if (PAIRING == true){  
                YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
                THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
                ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
                PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
                CoDrone.Control();   
                }
            }
            

            I highly suggest adding a kill switch or a landing event to the code before flying or else you may not be able to stop the drone from flying.
            Note: The kill switch makes the drone completely stop in the air. I suggest using it when the drone is near the floor or in the case that you need to make an emergency stop (like if it's about to hit someone).

            Here is the exact code I used to test (kill switch added):

            #include <CoDrone.h>
            
            void setup() {
                CoDrone.begin(115200);
                CoDrone.AutoConnect(NearbyDrone);
            }
            
            void loop() {if (PAIRING == true){  
                YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
                THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
                ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
                PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
                CoDrone.Control();   
                }
            
                if(digitalRead(11) && !digitalRead(14) && !digitalRead(18)) //bottom left sensor
                {
                  CoDrone.FlightEvent(Stop); // Kill switch
                  //CoDrone.FlightEvent(Landing); // Landing event
                  CoDrone.Buzz(4000, 7);
                  delay(100);
                }
            }
            

            Hope it helps!

            1 Reply Last reply Reply Quote 3
            • First post
              Last post