Functions Guide

Here we provide short descriptions of some of the more useful CoDrone functions included in the CoDrone Arduino Library.  This page will be updated as the CoDrone library develops.

Screen Shot 2016-05-21 at 4.18.32 PM
Contents:
  1. Begin
  2. Connect
  3. LEDs
  4. Control
  5. Events
  6. Receive
  7. Link Bluetooth
  8. Battle
  9. Trim
  10. Miscellaneous


Begin

#include <CoDrone.h>

  • The #include function tells Arduino that we plan to use the CoDrone.h library.
  • This allows the use of all CoDrone class functions and variables.
  • Be sure to include this line at the top of your code, before void setup().

CoDrone.begin(115200);

  • 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.

Connect

AutoConnect(NearbyDrone);

  • Automatically connect to a nearby CoDrone.  
  • The code will not move past this function until a connection has been found.

AutoConnect(ConnectedDrone);

  • Automatically connect to the previously connected CoDrone.  
  • The code will not move past this function until a connection has been found.

AutoConnect(AddressInputDrone, droneAddress);

  • Automatically connect to the specified CoDrone
  • Replace AddressInputDrone with your specific drone’s address (see PrintDroneAddress()).
  • The code will not move past this function until a connection has been found.

Send_Disconnect();

  • Disconnect from the currently connected drone.

PrintDroneAddress();

  • Print the unique address of the current drone to the serial monitor.
  • The controller must be plugged into the computer

Example


  LEDs

When changing the CoDrone’s LEDs, keep in mind that the color change will remain until a new color is sent or the drone is powered off.

LedColor(mode, color, interval);

  • Set the mode, color and interval of the drone’s LEDs using a preset color (color table below)

LedColor(mode, R, G, B, interval);

  • Set the mode, color and interval of the drone’s LEDs using R B G values.  
  • Each R B G value can range from 0 to 255.

The LED functions utilize three settings:

Mode : The mode determines which LEDs to control and the style of control

Color : The color setting allows the user to select the color of the LED.  The user can choose a preset color, or an RGB color combination. 

Interval : The interval determines the interval of the selected mode.  If flicker is selected, the rate of flickering will be determined by the interval.  This number can range from 0 to 255. 

EyeNone

EyeHold

EyeMix

EyeFlicker

EyeFlickerDouble

EyeDimming

ArmNone

ArmHold

ArmMix,

ArmFlicker

ArmFlickerDouble

ArmDimming

ArmFlow

ArmFlowReverse

AliceBlue, AntiqueWhite, Aqua,  Aquamarine, Azure, Beige,  Bisque, Black,

BlanchedAlmond,  Blue, BlueViolet, Brown,BurlyWood, CadetBlue, Chartreuse,

Chocolate, Coral, CornflowerBlue,  Cornsilk, Crimson, Cyan, DarkBlue, DarkCyan,

DarkGoldenRod,  DarkGray, DarkGreen, DarkKhaki,  DarkMagenta, DarkOliveGreen,

DarkOrange, DarkOrchid, DarkRed,DarkSalmon,  DarkSeaGreen, DarkSlateBlue,

Darkslategray, darkturquois to, darkviolet, deepp Link, deepskyblu to,dimgray,

DodgerBlue,FireBrick, FloralWhite, ForestGreen,  Fuchsia, Gainsboro, GhostWhite,

Gold, GoldenRod, Gray, Green,GreenYellow, HoneyDew,  HotPink, IndianRed, Indigo,

Ivory, Khaki, Lavender,  LavenderBlush, LawnGreen, LemonChiffon,LightBlue,

LightCoral, LightCyan, LightGoldenRodYellow, LightGray, LightGreen,  LightPink,

LightSalmon, LightSeaGreen,LightSkyBlue, LightSlateGray, LightSteelBlue, LightYellow,

Lime, LimeGreen, Linen, Magenta, Maroon, MediumAquaMarine,MediumBlue,

MediumOrchid, MediumPurple, MediumSeaGreen, MediumSlateBlue,MediumSpringGreen,

MediumTurquoise,MediumVioletRed,  MidnightBlue, MintCream,MistyRose, Moccasin,

NavajoWhite, Navy, OldLace, Olive, OliveDrab, Orange,OrangeRed,Orchid,PaleGoldenRod,

PaleGreen, PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff,Peru, Pink, Plum,

PowderBlue, Purple, RebeccaPurple,Red, RosyBrown, RoyalBlue,SaddleBrown, Salmon,

SandyBrown, SeaGreen, SeaShell,Sienna, Silver, SkyBlue,SlateBlue, SlateGray,Snow,

SpringGreen, SteelBlue, Tan, Teal, Thistle, Tomato, Turquoise, Violet,Wheat, White,

WhiteSmoke, Yellow, YellowGreen

Example

 


Control

Control();

  • Send the steering maneuvers to the CoDrone.  Leaving the field empty defaults to 50 (ms).

Control(Interval);

  • Send the steering maneuvers to the CoDrone at the set interval.  The interval is a number in milliseconds.  The default is 50 (ms).  Using the variable SEND_INTERVAL sends 50 (ms). 

The CoDrone is controlled by four variables:

Throttle: The vertical up and down movement of the drone

Yaw: The left and right rotation of the where the drone is facing

Roll: The left and right movement of the drone

Pitch: The backward and forward movement of the drone

Learn more here

Each set of motor commands must be followed by a Control() command.  This sends the manuever to the drone for execution.

Interval: The interval determines the rate of the send command.  The default is 50 (ms).  Communication with the drone occurs at intervals of 50ms.

 

Example


Events

DroneModeChange(event);

  • Sets the mode of the drone.  
  • Flight mode sets the drone into fly mode for default drone flight, controlling all 4 motors
  • Drive mode sets the drone into drive mode for the car wheels configuration, controlling only the front two motors.
  • Using modes that do not fit the hardware of the drone will lead to performance issues
  • The CoDrone’s mode will be saved even after the drone is turned off

Example

 

FlightEvent(event);

  • Sends the event to the CoDrone
  • Events are often short maneuvers such as TakeOff, Landing and Flip

Takeoff

FlipFront

FlipRear

FlipLeft

FlipRight

Stop

Landing

Reverse

Shot

UnderAttack

CircleLeft

CircleRight

Rotate180

Example


Receive

Receive();

  • Receives and processes the information from the CoDrone and stores the information into the proper variables.
  • Note that you need to request information from the CoDrone so that the CoDrone will send the information.

LowBatteryCheck(Level);

  • Gets the battery level and checks to see if it has dropped below Level percentage. If it is below Level it will beep a warning sound 5 times.
  • Level can be a value from 0 to 100

Example


Link Bluetooth

Send_LinkModeBroadcast(Mode);

  • Changes the mode of the communication between the SmartInventor board and the Bluetooth board to the inputted mode.
  • LinkModeMute: Stops communicating with the the Bluetooth module so that it can communicate to the computer for downloading programs and using the Serial monitor.
  • LinkModeActive: Uses the Bluetooth module to communicate with the CoDrone
  • LinkModePassive: Uses the Bluetooth communications, but it does not send any messages out from the board.

LowBatteryCheck(Level);

  • Gets the battery level and checks to see if it has dropped below Level percentage. If it is below Level it will beep a warning sound 5 times.
  • Level can be a value from 0 to 100

Example

LinkReset();

  • Reset the connection between the SmartInventor board and the Bluetooth board
  • Any CoDrones that are paired with the controller will be unpaired

Example


Battle

BattleBegin(TeamSelect);

  • Battle Begin initiates the battle mode, and Team Select allows the player to select a team:
    • TEAM_RED/TEAM_BLUE/TEAM_GREEN/TEAM_YELLOW/FREE_PLAY
  • Players on the same team cannot take damage from each other.  Free Players can take damage from anyone.
  • Team color will be reflected by the drone’s LED lights
  • Each player begins with 8 hit points.  Each time the player is shot, they lose 1 hit point.  When the player has 0 hit points, the drone is out.

BattleShooting();

  • Commands the CoDrone to shoot
  • The drone will also ‘recoil’ from the shot and move backwards slightly
  • Each shot does 1 hit point of damage

BattleReceive();

  • Checks if the drone was attacked
  • If the drone was attacked, the LED and buzzer will activate for a short period

CrashCustom(boolean custom);

  • Set to true to enable “CrashedCheck()” function
  • Default is false

boolean CrashedCheck();

  • Returns True is the CoDrone is out of HP
  • Returns False otherwise
  • Only works when CrashedCustom is set to true (i.e. CrashedCustom(true);)

BattleHitPoints(int points);

  • Sets the starting hit points for battle
  • range from 1-8
  • default is 8 hit points

Example


Trim

These functions show how to set the trim of the CoDrone. The trim is a offset to remove the problems of motors moving at different speeds. This is what helps to make the CoDrone fly straight and be able to hover in place.  Learn more here.

Trim is retained on the CoDrone even when it is turned off.

Set_Trim(Direction);

  • Adjusts the current value of the trim depending on the event. It will move the trim by 1 in the direction specified by the event.

 

RollIncrease

RollDecrease

PitchIncrease

PitchDecrease

YawIncrease

YawDecrease

ThrottleIncrease

ThrottleDecrease

 

Set_TrimAll(Roll, Pitch, Yaw, Throttle, Wheel);

  • Sets the trim to the given values for each direction. It sets the trims not just for the flight, but also for the steering (wheel, used in drive mode). Each value must be from -500 to 500.

Set_TrimFlight(Roll, Pitch, Yaw, Throttle);

  • Sets the trim to the given values for each direction. It sets the trims just for the flight. Each value must be from -500 to 500.

Set_TrimDrive(Wheel);

  • Sets the trim for the drive mode.

Example


Miscellaneous

ButtonPreesHoldWait(button);

  • Sets a delay while the button is pressed.  This prevents the button from being pressed multiple times on accident

ButtonPreesHoldWait(button,button);

  • Sets a delay while the buttons are pressed.  This prevents the button from being pressed multiple times on accident.  

AnalogScaleChange(AnalogValue);

  • Remaps the input range of an analog joystick (from 0 to 1023).  The range is defined from -100 to 100.
  • The CoDrone Remote joystick value sends analog values of 0 to 1023.  To use these values in our PITCH ROLL YAW THROTTLE commands, we use AnalogScaleChange to remap the values to value ranging from -100 to 100.

Buzz(frequency, tempo);

  • Tells the CoDrone remote to make a buzzing noise from the buzzer.  The frequency and tempo of the the buzz can be set

BeepWarning(count);

  • Tells the CoDrone remote to make a beeping noise
  • Set the amount of beeps in count


Creative Designers

Awesome & skilled
Designers.

12

Awards

78

Portfolio Projects

22

Happy Clients


Creative Studio

We love what we do.

Digital agency.


We design products, packaging and user experiences with a unique research-based process i call Informed Creativity. Our work has been recognised with multiple international awards and widely covered in the press.

About Us

Let’s Talk.


We work for the most innovative and best-loved companies in the world.

Contact

Awesome stuff.

Advanced Grid

Truly one of the most powerful and advanced grid system with equal-height columns.

Digital Branding

Uncode comes with pixel perfect & clean design to satisfy any possible an impossible needs.

Top Performance

Automatically adapt and set your images for best quality on all devices and resolutions.

Responsive Design

A perfect responsive theme powered with selective options for different screen resolutions.

525

Layouts

23

Awards

745

Cups of Coffee

78

Projects

“Dream big, work hard and surround yourself with love.”

Fresh news.


Creative Artist

New Album


Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley.

Latest Video


‘Changes’ Videoclip 2105

Soundcloud Mixes


Photo Gallery


Latest News


VEX IQ Information

Blockly for Robolink

Carl POC


Creative Event

Two days in London.


Each year digital architects, pixel visionaries and curators of dreams alike, come together in iconic cities all over the world to share with us their best-kept secrets. Obsessive, passionate, scrupulous and meticulous; always creative; always brave.

Web Design

It’s an uncommon gathering for those who understand and want to learn more about.

Event Schedule.

If have enough people wanting to attend the same course then we can run one just for you. If you prefer to study in your own time and learning packages.

Thursday, 04


10:00am
PRACTICAL UX METHODS
Patrick McNeil

14:30am
SIMPLIFY YOUR SITE
Barry Clark

Friday, 05


10:00am
CSS OVERLOAD
Patrick McNeil

14:40am
RESPONSIVE TRICKS
Stephan Wink

The speakers.


Tobias van Schneider
Independent Designer
USA

Mathias Høst Normark
Art Director & Designer
DENMARK

32

Workshops.

Register yourself.

City Hotel.


If you chose to stay with us you will enjoy modern home comforts in a traditional setting. Whether you are looking for a short weekend break for you.

Book reservation

Thanks our Sponsors.

An effective sponsor thank you letter is vital to build for the future.


Creative Freelance

APP DEVELOPMENT

Credibly brand standards compliant users without extensible services. Dramatically communicate effective resources for intermandated web services.

RESPONSIVE DESIGN

Credibly brand standards compliant users without extensible services. Dramatically communicate effective resources for intermandated web services.

PIXEL PERFECT

Credibly brand standards compliant users without extensible services. Dramatically communicate effective resources for intermandated web services.

24

Web Awards

42

Happy Clients

86

Blog Posts

18

Speech

Creative Agency

Our works

Always strive for better work. Never stop learning. Have fun.


525

LAYOUTS

23

AWARDS

745

CUPS OF COFFEE

78

PROJECTS

Let’s blog

We love clean design and advanced digital solutions.


Responsive Design

Powered Page Builder

Outstanding Support

Get in touch

A clear plan for a new project or just an idea on a napkin?


OUR OFFICE

Lorem Ipsum is simply dummy

open map

DROP A LINE

Lorem Ipsum is simply dummy

send email

SUPPORT

Lorem Ipsum is simply dummy

open ticket