Beginners Series Lesson 1: Setup
The first lesson in this series will begin with the basics of how to use the Arduino IDE and CoDrone Controller


Uploading Code:
Before beginning this lesson, make sure you learn how to properly compile and upload code to the CoDrone Controller by reviewing Uploading Code.


How Computers Read Code

To learn how to write code, the first thing we need to understand is how the computer reads code.

Arduino IDE

Here is what your Arduino window looks like.  You will write all your code within this environment.  The code we write will then be uploaded to the computer in the SmartInventor Board.

When reading your code,

  1. Computers only understand certain words
  2. Computers read from top to bottom.
  3. Computers read one line at a time.
  4. Computers are case sensitive.


1. Computers only understand certain words

When writing our programs, we need to make sure to use words that the computer knows.

For example, if I want my CoDrone to fly upwards, I can’t just write

The computer doesn’t know what “Fly Upwards” means.  Instead, we would write

Throughout these lessons you will learn hundreds of different commands and how to use them.  In later lessons, you will even learn how to write and name your own functions.

2. Computers read from top to bottom

Our code will always be read from top to bottom, just like how we read books.


3. Computers read one line at a time

This means that each line is read one at a time.  Our SmartInventor Board can only execute a command when it reads it, so this also means that the computer can only execute a single command at a time.

It’s also important to remember that computers can read extremely fast.  Some programs can be read hundreds of thousands of times each second.  Even though our program is being executed one line at a time, it can seem like it’s all happening at once because of how quickly the computer is reading.


4. Computers are case sensitive

Capitalization matters!


is not the same as this

Make sure you always use the right capitalization.


Now let’s learn about how to setup your CoDrone code.  In the next few lessons, we will cover coding basics, expand our programming vocabulary, and learn how to get our CoDrones into the air.


Setting Up Your CoDrone Code

The first thing we must do at the beginning of every CoDrone code is include the CoDrone Library.

What’s a library?

A library is a saved set of functions()  and variables that can be called.  For example, if we know that we always want the CoDrone to takeoff by throttling up slowly for 3 seconds, we can save time and memory by saving this function in a CoDrone library.  Instead of telling the drone to “throttle up slowly for 3 seconds” every time now we can simply tell it to “takeoff” and the drone will perform the ‘takeoff’ function.

Any code that starts with CoDrone._____  is a function in the CoDrone library.

Learn More

By including the CoDrone library, we can now utilize all the CoDrone functions in the rest of our code.

Next, we need to initialize our connection to the bluetooth module using the function CoDrone.begin() .  


CoDrone.begin(Baud Rate)

  • The begin function initializes the serial connection between the Smart Inventor board and the Bluetooth Module.
  • 115200 is the Baud rate of the serial connection.  This must be set to 115200.
  • This function must appear at the beginning of your code within void setup() to allow data to be sent to and from the Bluetooth Module.

The bluetooth module is the black board connected to the SmartInventor board:


The bluetooth module uses the Serial communication at a baud rate (the communication speed in bytes per second) of 115200, so we will tell the CoDrone to begin at a baud rate of 115200.

Next we need to pair with the CoDrone.  There are a few ways to do this (which we will discuss more in later lessons), but for now we will use the function CoDrone.AutoConnect(NearbyDrone) 

Remembering that code reads downwards, we need to make sure that we put CoDrone.begin(115200)  first, then CoDrone.AutoConnect(NearbyDrone) .

This is all you need to have your drone set up and paired!

Note that this does not make your CoDrone fly.  This program only establishes a connection between the drone and the bluetooth module.


Final Code:

Activity: Friends Forever

Try to pair with your CoDrone.  The green light on the back of the CoDrone flashes when it is unpaired, and becomes solid when it is paired.

CoDrone back view with lights on


Next, we’ll discuss the different possible methods of pairing and when you should use them.