Introduction To Coding Drones!
CoDrone and Blockly
Level 1- Introduction
Introduction to Coding Drones!
I. Drone Overview and Calibration -
-
“A journey of a thousand miles begins with a single step.” —Lao Tzu
-
-
The Gyro and Accelerometer
Gyro (Gyroscope):Measures the rotational movement of the drone.
Helps maintain stability and orientation.
Ensures smooth and controlled turns.
Illustration:Imagine spinning in place and then trying to stop suddenly. Your body would naturally try to stabilize itself to prevent falling. The gyroscope in a drone does something similar, detecting rotational movements to keep the drone steady.
Accelerometer:
Measures the drone's acceleration in different directions.
Detects changes in speed and direction.
Helps maintain level flight and detect tilting or shaking.
Picture yourself in a car that suddenly accelerates. You feel pushed back against the seat. The accelerometer in a drone senses this kind of movement, detecting changes in speed and direction to help keep the drone level and balanced.
-
Remove the Battery:
Pop out the battery from the drone.
Reinsert the Battery:
Press the Button:
Flip drone upside down.
Hold down the small button on the side of the drone.
Wait for Lights:
Watch for the lights to change (usually purple, white, then green), indicating calibration mode.
Release the Button:
Release the button once the lights indicate calibration is in progress.
place the drone on that flat well lit surface!
-
-
CoDrone Safety Steps Summary
Avoid Grabbing from the Top:
Do not grab the drone from the top to prevent propeller injuries.
Secure Long Hair:
Students with long hair should tie it into a ponytail to avoid tangling.
Hair Removal from Propellers:
Remove the battery, lift the propeller, and untangle the hair.
Propeller Orientation:
Ensure propellers are correctly positioned based on markings.
Avoid Water:
Do not fly the drone near water to prevent damage.
If using REMOTE Handle Bluetooth Module Gently:Treat the Bluetooth module with care to avoid damage.
Managing CoDrone in a Classroom Setting
Pre-Class Preparation:
Review and test the code you'll be using.
Ensure CoDrones, laptops, USB cables, and batteries are ready.
Classroom Setup:
Divide the room into sections for programming and flying.
Have multiple batteries charging.
Student Preparation:
Students with long hair should tie it up.
Verify students' code before handing out batteries.
Testing:
Use a micro USB cable for the Bluetooth module or remote.
Test the code with the drone in hand to feel movements.
Group Work and Troubleshooting:
Form student groups to minimize chaos.
Teach students proper troubleshooting techniques.
The entire Codrone Robolink Curriculum van be found at https://learn.robolink.com/ . Take a look at their EXTENSIVE Resources!
History Lesson: On July 20, 1969, American astronaut Neil Armstrong became the first person to walk on the moon, a momentous achievement for the United States in the Space Race.
Quote: "That's one small step for man, one giant leap for mankind." — Neil Armstrong
Motivational Message: Just like the brave astronauts who ventured into the unknown, you have the potential to reach new heights and achieve incredible things with your drone skills. Dream big and soar high!
Introduction to BLOCKLY!!
II. BLOCKLY!!
-
“If you want your dreams to come true, GET OUT OF BED!”
Read Through Requirements for running Blockly
https://learn.robolink.com/lesson/codrone-introduction-to-blockly/
I read Through Requirements for running Blockly
I am running Windows 10 with Version 1803 or greater
If you are using Mac OS, you should have 2012 hardware or newer.
Check Bluetooth is enabled and on.
Google Chrome version is the latest
-
Make sure you save! You can do this by going to the menu in the upper lefthand corner of the workspace and clicking on “Save”. To open a saved program, go to the same menu and click on “Open…”.
Open the Flight Commands Menu on the left.
Drag "takeoff" to the workspace in the middle of the page.
Open the Flight Commands Menu again and Drag "land" to the workspace in the middle of the page. Connect the block to the Takeoff Block.
If you need to delete blocks, separate what you want to get rid of from your code and drag them to the trashcan in the lower righthand corner.
Want to see what your code looks like in Python?? Click on one of the coding lan
-
Once you’re ready to run your code, connect to your CoDrone by clicking on the green connect button in the bottom lefthand corner.
A list of devices should come up. Select the one that says “Petrone (# on the underside of your drone)”.
Once you have connected your drone and want to use the same one next time, click on “Pair with Previous” instead.
-
Required to answer. Multiple choice.
Review the Safety Steps Checklist leaned in previous lesson.
On the top lefthand side of your workspace Click on “Run code”. If you followed the above instructions, your drone should take off, hover for a second or two and land.
If you need to stop your drone for any reason during its flight, click on “Stop”, which is right next to the “Run code” button..
History Lesson: The Wright brothers, Orville and Wilbur, made the first controlled, powered, and sustained flight on December 17, 1903, in Kitty Hawk, North Carolina.
Quote: "The desire to fly is an idea handed down to us by our ancestors who... looked enviously on the birds soaring freely through space." — Wilbur Wright
Motivational Message: The Wright brothers' innovation and determination remind us that no dream is too big. With perseverance and creativity, you can revolutionize the future of aviation and drone technology.
III. FLIGHT COMMANDS
-
“The beginning is the most important part of the work.” —Plato
Click on the blue flight commands menu. Look at all the possible commands. The take off and land blocks should be at the top!
Add a take off to your workspace by dragging it out.
Add a land to your workspace by dragging it out. Attach the blocks together!
-
Hover
If you want your CoDrone to hover for more than three seconds, there is a way to do that! Find the hover for _ seconds block in the flight commands menu and connect it to the bottom of the take off block. Next, type in the number of seconds you would like your CoDrone to hover for.
-
There might be times when your CoDrone is about to crash into something and you need to have it make an emergency stop before it does serious damage. If you want your CoDrone’s motors to stop without crashing into the ceiling first, program a kill switch by dragging a rounded when _ key press block from the gray keyboard inputs menu into the workspace. This should be the block that doesn’t have a connector on the side! Pick the key you would like to use to stop your drone from the block’s drop-down menu, but as a warning, using the backspace key can sometimes delete blocks of code!
Next, go to the flight commands menu, find the emergency stop block, and drag it into the when _ key press block.
Note: this will be a separate program but will be in the same workspace!
-
Can you make the drone do push ups? In Other Words take off and land repeatedly?
For clues
-
5.
SAVE YOUR CODE
Click the Menu HAMBURGER next to the Run Code
Click Save
Save as any name you want, but I saved mine as "Basic Flight Commands-Junior"
History Lesson: On April 15, 1947, Jackie Robinson broke the color barrier in Major League Baseball by playing for the Brooklyn Dodgers, becoming the first African American to play in the MLB in the modern era.
Quote: "A life is not important except in the impact it has on other lives." — Jackie Robinson
Motivational Message: Jackie Robinson's courage and talent paved the way for future generations. Approach your drone training with the same determination and know that your efforts can inspire and create opportunities for others.
Learn about Drone Light Shows!!
IV. Flight Directions!
-
“Beyond the edge of the world there’s a space where emptiness and substance neatly overlap, where past and future form a continuous, endless loop. And, hovering about, there are signs no one has ever read, chords no one has ever heard.”
― Haruki Murakami
The lesson on CoDrone Blockly Jr. flight directions covers programming the CoDrone to move in various directions (up, down, forward, backward, side to side), turn, and fly specific patterns.
Key steps include using blocks to control flight duration and power, turning for specific times or degrees, and combining commands for complex movements. A challenge encourages students to program the CoDrone to fly in geometric shapes using these commands. For more details, visit Robolink's Flight Directions.
-
The steps for learning turns with CoDrone Blockly Jr. include:
Programming Turn Commands: Use blocks to program the CoDrone to turn left or right.
Setting Turn Duration or Angle: Specify the duration or angle for the turn using appropriate blocks.
Combining Turns with Other Movements: Integrate turn commands with other flight movements like forward or backward.
Practicing with Challenges: Apply the learned turning skills in practice challenges, such as making the drone turn at specific intervals or angles while flying.
For detailed instructions, visit Robolink's Flight Directions.
-
Practice Exercise 1: Basic Turns
Take Off: Use the "takeoff" block.
Hover: Add a "hover" block for stability.
Turn Right: Insert a "turn right" block set for 2 seconds.
Hover: Add another "hover" block to stabilize after turning.
Land: End with the "land" block.
Practice Exercise 2: Square Flight Pattern
Take Off: Use the "takeoff" block.
First Side: Move forward for 3 seconds, then turn right 90 degrees.
Second Side: Move forward for 3 seconds, then turn right 90 degrees.
Third Side: Move forward for 3 seconds, then turn right 90 degrees.
Fourth Side and Land: Move forward for 3 seconds, turn right 90 degrees, and land.
Practice Exercise 3: Zigzag Pattern
Take Off: Use the "takeoff" block.
First Move: Move forward for 2 seconds, then turn left 45 degrees.
Second Move: Move forward for 2 seconds, then turn right 90 degrees.
Repeat Pattern: Repeat the forward and turn sequence for a total of three zigzags.
Land: Stabilize with a hover and then use the "land" block.
For more detailed instructions, visit Robolink's Flight Directions.
-
Challenge: Shapeshifter
Have your CoDrone fly in a shape using all of the commands you just learned! The only rule is that you HAVE to include a kill switch.
Some helpful hints:
A triangle’s angles add up to 180 degrees.
A quadrilateral’s angles add up to 360 degrees.
A pentagon’s angles add up to 540 degrees.
A hexagon’s angles add up to 720 degrees.
An octagon’s angles add up to 1080 degrees.
History Lesson: On May 6, 1954, Roger Bannister became the first person to run a mile in under four minutes, achieving a time of 3:59.4.
Quote: "The man who can drive himself further once the effort gets painful is the man who will win." — Roger Bannister
Motivational Message: Roger Bannister's achievement reminds us that breaking barriers requires pushing past limits. Apply this mindset to your drone projects, pushing yourself to achieve what seems impossible.
V. Flight Conditionals and Variables
What are Conditionals!?
-
"My mission is to create a world where we can live in harmony with nature." - Jane Goodall
What are Conditionals?
Conditionals are statements that help programs make decisions based on whether a condition is true or false. In Blockly, conditionals include if, else if, and else statements. You use conditionals to make decisions in everyday life. Here are examples:
If Statements:
If it is raining, then I will take an umbrella.
If I am hungry, I will eat lunch.
If-Else Statements:
If it is raining, then I will take an umbrella. Else, I will wear sunglasses.
If I am hungry, I will eat lunch. Else, I will wait until dinner.
If-Else If-Else Statements:
If it is raining, then I will take an umbrella. Else if it is cloudy, I will take a jacket. Else, I will wear sunglasses.
If I am hungry, I will eat lunch. Else if I am thirsty, I will drink water. Else, I will continue working.
Conditionals in Blockly
In Blockly, conditionals are used similarly:
If Statement: If the CoDrone's battery is low, then the CoDrone will land.
If-Else Statement: If the CoDrone's battery is low, the CoDrone will land. Else, the CoDrone will continue flying.
If-Else If-Else Statement: If the CoDrone's battery is low, the CoDrone will land. Else if an obstacle is detected, the CoDrone will hover. Else, the CoDrone will continue flying.
-
Practice Exercise 1: Simple Addition Check
Objective: Program the CoDrone to react based on a math condition.
Condition: If 3 + 2 equals 5.
Action: Then, the CoDrone will take off.
Else: The CoDrone will stay on the ground.
Test: Run the program to check if the CoDrone takes off.
Modify: Change the addition equation and observe the behavior.
Practice Exercise 2: Greater Than Comparison
Objective: Program the CoDrone to react based on a comparison.
Condition: If 7 is greater than 4.
Action: Then, the CoDrone will flash its LED lights.
Else: The LED lights will remain off.
Test: Run the program to see if the LEDs flash.
Modify: Change the numbers in the comparison and test again.
Practice Exercise 3: Equal Value Check
Objective: Program the CoDrone to react if two values are equal.
Condition: If 10 - 3 equals 7.
Action: Then, the CoDrone will spin in a circle.
Else: The CoDrone will hover in place.
Test: Run the program to see if the CoDrone spins.
Modify: Change the subtraction equation and test the reaction.
-
What are Variables?
Variables are used to store information that can be referenced and manipulated (used) in a program. In Blockly, variables are like containers that hold values, which can change as the program runs. You use variables in daily life to keep track of changing information. Here's how you might use a variable, typically seen as “set ____ to ____”:
Set my age to 10.
Set the temperature to 75°F.
Variables can also be updated as conditions change:
Set my age to my age + 1 on my birthday.
Set the temperature to the current temperature reading every hour.
In Blockly, variables allow dynamic control and data management. For example:
Set Variable: Set altitude to 10 meters.
Update Variable: Set altitude to altitude + 1 meter every second.
-
Practice Exercise 1: Setting X and Y Variables for Movement
Objective: Program the CoDrone to move right and forward using variables.
Create Variables: Create variables named "x" and "y."
Set Initial Values: Set "x" to 3 and "y" to 2.
Move Right: Use the "x" variable and Flight Directions to move right by 3 units.
Move Forward: Use the "y" variable and Flight Directions to move forward by 2 units.
Test: Run the program to see the CoDrone move right and then forward.
Practice Exercise 2: Using Variables in Movement
Objective: Program the CoDrone to move based on variable values.
Create Variables: Create variables named "x" and "y."
Set Initial Values: Set "x" to 10 and "y" to 10.
Move Command: Use the "x" and "y" variables to control the CoDrone's movement distance.
Change Values: Adjust "x" to 15 and "y" to 5.
Test: Run the program to see the CoDrone move accordingly.
Practice Exercise 3: Conditional Movement with Variables
Objective: Program the CoDrone to decide movement based on variable values.
Create Variables: Create variables named "x" and "y."
Set Initial Values: Set "x" to 7 and "y" to 7.
Condition Check: If "x" is equal to "y," move forward.
Change Values: Set "x" to 10 and "y" to 7.
Test: Run the program to observe the CoDrone's behavior based on the condition.
For more detailed instructions, visit Robolink CoDrone Blockly Jr. Variables.
-
Classroom Challenge: Desk Navigation
Objective: Program the CoDrone to navigate around desks and chairs in a classroom, using conditionals and variables.
Parameters:
Start Point: Define a starting point at the front of the classroom.
Obstacles: Arrange desks and chairs to create a path with obstacles.
Variables: Create variables named "x" and "y" to track the CoDrone’s movement along the path.
Conditionals: Use conditionals to check for obstacles and adjust the drone’s path:
If an obstacle is detected within 10 cm, move up.
If no obstacle is detected, continue moving forward.
Goal: Successfully navigate the CoDrone from the starting point to a designated end point (e.g., a specific desk or the back of the classroom).
Science Lesson: Charles Darwin’s theory of evolution, published in "On the Origin of Species" in 1859, fundamentally changed our understanding of life on Earth.
Quote: "It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change." — Charles Darwin
Motivational Message: Darwin’s work teaches us the importance of adaptability and understanding our environment. As you develop your drone skills, be open to learning and adapting, always respecting the natural world around you.
VI. Loops & LEDs
Science Lesson: On March 2, 1972, NASA launched the Pioneer 10 spacecraft, which became the first human-made object to travel through the asteroid belt and provide close-up images of Jupiter.
Quote: "Exploration is really the essence of the human spirit." — Frank Borman
Motivational Message: Pioneer 10’s journey represents humanity’s drive to explore the unknown. Use your drones to explore and learn about the natural world, fostering a spirit of curiosity and respect for the environment.
-
"Make your life a mission - not an intermission." - Arnold H. Glasgow
Introduction to LoopsLoops allow you to repeat sections of code efficiently. Blockly has three types of loops:
For Loops: Repeat code a specific number of times.
While Loops: Repeat code as long as a condition is true.
Until Loops: Repeat code until a condition is true.
Using For Loops
For loops repeat code a set number of times. Blockly offers two for loop blocks:
Repeat _ times: Specify a number directly or use a variable.
Count with: More advanced, using a variable to count within a range.
Access Blockly: Open the CoDrone Blockly interface.
Find the For Loop Block:
Locate the "Loops" category in the Blockly toolbox.
Drag the "repeat _ times" block or the "count with" block to the workspace.
Set the Loop Count:
For "repeat _ times": Enter the number of iterations directly.
For "count with": Define the variable, start value, end value, and step size.
Add Actions:
Place the actions you want to repeat inside the loop block.
Examples include moving the drone, changing LED colors, or playing sounds.
Run the Program: Upload the code to your drone and observe the repeated actions.
For more detailed examples and instructions, visit Robolink's CoDrone Blockly Jr Loops Lesson.
-
While Loops
While loops repeat code while a condition is true. Use them to perform actions repeatedly based on dynamic conditions.
Until Loops
Until loops function like while loops but run until a condition is true, useful for tasks needing repetition until a specific event occurs.
Explore more at Robolink's CoDrone Blockly Jr Loops Lesson.
While Loops
Access Blockly: Open the CoDrone Blockly interface.
Find the While Loop Block:
Go to the "Loops" category in the Blockly toolbox.
Drag the "while" block to the workspace.
Set the Condition:
Define the condition that needs to be true for the loop to execute.
Example: while (battery level > 20%).
Add Actions:
Place the actions you want to repeat inside the while block.
Examples: move forward, turn left, etc.
Run the Program: Upload the code to your drone and observe the repeated actions until the condition is false.
Until Loops
Find the Until Loop Block:
In the "Loops" category, find the "repeat until" block.
Drag it to the workspace.
Set the Condition:
Define the condition that needs to be true for the loop to stop.
Example: until (distance < 10cm).
Add Actions:
Place the actions you want to repeat inside the until block.
Examples: hover, change LED color, etc.
Run the Program: Upload the code to your drone and observe the repeated actions until the condition becomes true.
For detailed examples and further guidance, visit Robolink's CoDrone Blockly Jr Loops Lesson.
-
Practical Examples
Program a Stair-Climbing Drone: Use for loops to make the drone ascend steps.
Shape-Flying Drone: Use while loops to fly in geometric patterns.
Disco Drone Challenge: Use loops to create dynamic LED light patterns on the drone, like a disco ball. Add music to make it more interesting.
-
What is an LED?
An LED (Light-Emitting Diode) is a small electronic component that emits light when electricity passes through it. Unlike traditional incandescent bulbs, which use a filament that heats up to produce light, LEDs use a semiconductor to emit light. This makes LEDs much more energy-efficient and longer-lasting.
LEDs on Your CoDrone
Your CoDrone is equipped with 6 RGB LEDs: one on each arm, one for the eyes, and one for the tail. RGB stands for red, green, and blue, and by combining these colors, you can create almost any color imaginable.
Traditional Bulbs vs. LEDs
Traditional Bulbs:
Mechanism: Use a filament that heats up to produce light.
Energy Use: Consume more power, as a lot of energy is lost as heat.
Lifespan: Shorter lifespan, often needing replacement.
LEDs:
Mechanism: Use a semiconductor to emit light when an electric current passes through.
Energy Use: More efficient, using less power to produce the same amount of light.
Lifespan: Much longer lifespan, reducing the need for frequent replacements.
LEDs on Your CoDrone
The CoDrone has 6 RGB LEDs: one on each of the four arms, one for the eyes, and one for the tail. These LEDs can be programmed to display a wide range of colors, not only making the drone look cool but also providing important feedback. For example, the tail light shows the drone's connection status: a solid green means it's connected, while a flashing green means it's in pairing mode. While the tail light's color is fixed, you can program the other LEDs to display any color and pattern you want.
-
Parameters for CoDrone LED Controls
CoDrone allows you to control the arm LEDs, eye LEDs, or both through the Lights menu. Each LED block has several parameters:
Color: Click on the color to open a menu and choose the desired LED color.
Brightness: For solid LED blocks, set the brightness from 0 (off) to 100 (full brightness).
Mode: Choose the light pattern:
BLINK: LEDs flash on and off.
DOUBLE BLINK: LEDs flash twice before turning off.
DIMMING: LEDs fade in and out.
Interval: Set the frequency (per second) for light patterns, ensuring the interval value is positive
Practical Elementary Exercises with CoDrone LED Parameters
Exercise 1: Color Fun
Objective: Change the color of the drone's LEDs.
Instructions:
Open the Lights menu.
Drag the "set arm LEDs to" block to the workspace.
Click on the color parameter and choose a color (e.g., red, blue, green).
Upload the code and observe the LEDs change color.
Exercise 2: Brightness Control
Objective: Adjust the brightness of the LEDs.
Instructions:
Select the "set arm LEDs to" block from the Lights menu.
Set the brightness parameter to different values (0, 25, 50, 75, 100).
Upload the code each time and observe the brightness change.
Exercise 3: Light Patterns
Objective: Explore different light modes.
Instructions:
Select the "set arm LEDs to" block.
Choose a mode: BLINK, DOUBLE BLINK, or DIMMING.
Set the interval (e.g., 1 second).
Upload the code and watch the LEDs display different patterns.
Exercise 4: Rainbow Cycle
Objective: Create a rainbow cycle with the LEDs.
Instructions:
Use multiple "set arm LEDs to" blocks.
Set each block to a different color (red, orange, yellow, green, blue, purple).
Arrange the blocks to change colors every 2 seconds.
Upload the code and watch the LEDs cycle through colors.
Exercise 5: Connection Status Indicator
Objective: Program the tail light to indicate connection status.
Instructions:
Select the "set tail LED to" block.
Program it to show solid green when connected and flashing green when in pairing mode.
Test the drone by connecting and disconnecting it, observing the tail light for status changes.
These exercises provide clear, step-by-step instructions to help students understand and experiment with CoDrone LED parameters in a hands-on and engaging way.
-
Understanding Morse Code
Morse Code: A communication system using a series of dots (short signals) and dashes (long signals) to represent letters, numbers, and punctuation. It was historically used in telegraphy and radio communications.
Dot: Short signal (e.g., short blink)
Dash: Long signal (e.g., long blink)
Exercise: Using Morse Code with Drone LEDs
Objective
Program your drone's LEDs to blink in Morse code to spell "SOS" (the universal distress signal).
Instructions
Open Blockly Interface:
Access the CoDrone Blockly interface.
Create Morse Code for SOS:
S: ... (dot-dot-dot)
O: --- (dash-dash-dash)
S: ... (dot-dot-dot)
Program Dots and Dashes:
Use the "set arm LEDs to" block.
For dots: Set a short blink (e.g., 0.2 seconds on, 0.2 seconds off).
For dashes: Set a long blink (e.g., 0.6 seconds on, 0.2 seconds off).
Arrange Blocks:
Sequence the blocks to create ... --- ... with appropriate delays between letters (e.g., 0.6 seconds).
Example Code:
python
Copy code
set LED to on for 0.2 seconds # Dot set LED to off for 0.2 seconds set LED to on for 0.2 seconds # Dot set LED to off for 0.2 seconds set LED to on for 0.2 seconds # Dot set LED to off for 0.6 seconds # Space between letters set LED to on for 0.6 seconds # Dash set LED to off for 0.2 seconds set LED to on for 0.6 seconds # Dash set LED to off for 0.2 seconds set LED to on for 0.6 seconds # Dash set LED to off for 0.6 seconds # Space between letters set LED to on for 0.2 seconds # Dot set LED to off for 0.2 seconds set LED to on for 0.2 seconds # Dot set LED to off for 0.2 seconds set LED to on for 0.2 seconds # Dot set LED to off for 0.6 seconds # End
Upload and Test:
Upload the code to your drone.
Observe the LEDs blink in Morse code, spelling "SOS".
This exercise teaches students how to use loops, timings, and LED control to create meaningful signals with their drones.
4o
The Morse Code alphabet and learn some letters.