- :-

Topics Covered

  • Functions
  • Lesson Links

    Check Your Understanding:
    1. 1. These allow the programmer to define a set of code once and then run that code multiple times.
    2. Encoders
      Functions
      Commands
      Variables
    3. 2. True / False: Functions force the user to write longer, less efficient programs.
    4. True
      False
    5. 3. True / False: Functions cannot be defined in Task Main or another function.
    6. True
      False
    7. 4. True / False: Functions with the keyword "void" return a value
    8. True
      False
    9. 5. Which of the following is not an example of a naming rule for a function?
    10. Must be all one word
      Made up of letters, numbers and underscores
      Names must begin with a capital letter
      Cannot be the same name as a ROBOTC reserved word
    Try It!
    Try it! 1

    Creating Function Library

    Make a list of behaviors that your robot does consistently (e.g. make a 90 degree right or left turn)



    Begin turning some of those behaviors into functions and save them in your function library.

    Try it!
    Try it! 2

    Backward One Line Function

    Create a program that utilizes a function to make the robot move backwards until the color sensor detects a line.



    Try it!
    Functions - Mini Challenge

    Mini Challenge 1: Lined Maze

    This challenge requires the robot to be programmed to navigate a maze.

    Each section of the maze requires an extra line to count.

    Students should use the one line function to help solve this challenge.
    • Recreate the table below on any surface, and colored tape to mark the boundaries. The robot must navigate the maze by counting lines.

    Mini Challenge PDF[ Lined Maze Challenge.pdf ]