PA Designer Learn 4: More Python Commands

This is the second challenge within the Robotics with GoPiGo and Python Curriculum.

Your task is to program your robot to alert a person with a hearing impairment to visiting house guests.

Learn how to use the Loudness Sensor alongside Jupyter Notebooks.

2. Let’s try a decision example

Let’s try an example by telling our robot to open its eyes if more than 5 seconds has elapsed. In our Main Code cell, enter the highlighted text just above the sleep instruction and click on Run Selected Cell. What behavior do you observe?

Main Code cell

# perform a time check and add elapsed time to end of the times list
    times.append(elapsed_time())

    # conditional statement
    if int(elapsed_time()) == 5:
        assistant.open_eyes()

    time.sleep(0.02)

Next, let’s look at what this code does.