The next thing you need to do is pair with your CoDrone! There are a few ways to do this which we’ll go over in another lesson, but for now, the easiest thing to do is use the function CoDrone.pair()
.
This next part is important. Read it as many times as you need to!
pair()
will just pair with whichever CoDrone you were last paired to. However, if this is your first time using the remote and you haven’t paired with a CoDrone with this particular remote, it will just pair with the first available CoDrone it finds, then lock in with that CoDrone. From that point on, it will always try to pair with that CoDrone. If you’d like to pair with a new drone, you can check out the next lesson: Unlocking a Remote-CoDrone Pair.
Since computers read code from top to bottom, this function needs to be underneath your baud rate.
void setup() {
CoDrone.begin(115200);
CoDrone.pair();
}
Student Tip:
This will not make your CoDrone fly! Sorry! This will just establish a Bluetooth connection between your CoDrone and your Bluetooth board.
Instructor Tip:
If you are setting this up in a classroom for the very first time, we highly recommend running through the pairing process in this lesson before class. This will lock your remotes in to specific CoDrones so that each remote will always pair with a specific CoDrone. Here’s what we recommend as prep before the class:
- Set the remote to upload mode by flipping DIP switch 1 up.
- Upload the final code in this lesson that specifically uses
pair()
.
- Set the remote in run mode by flipping DIP switch 1 back down.
- Pair with the desired CoDrone to lock that remote in to that CoDrone. Make sure all other remotes are off!
- Label the remote and CoDrone with an identifying number.
Make sure to do this one at a time. If you need to unlock the remote from a CoDrone and pair it to a new CoDrone, you can follow the steps in lesson Unlocking a Remote-CoDrone Pair.