PA Designer Learn 4: More Python Commands
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.