Lesson 3.4

Battery and While Loops

Lesson
3.4

Battery and While Loops

This lesson uses:

CoDrone EDU CoDrone EDU / CoDrone EDU (JROTC edition)
Python Python

In this lesson, students will use Python programming to explore how a drone’s battery level can be checked and used to control its behavior. They will learn how to use the get_battery() function to read the battery level and use while loops to repeat actions as long as a condition remains true. Students will also learn how Boolean values represent conditions that control when while loops continue or stop. By the end of the lesson, students will write programs that use the drone’s battery level to make decisions, such as flying and glowing green while the battery is above a certain value, then turning red and landing safely when the battery becomes low.