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!