Lesson Overview
You will use programming logic to make decisions, repeat actions, and control an automated sorting process. This example combines repeated pickup movement, optical sensor input, conditional decisions, and stacked placement locations.
Use programming logic to make decisions, repeat actions, and control automated processes.
You will use programming logic to make decisions, repeat actions, and control an automated sorting process. This example combines repeated pickup movement, optical sensor input, conditional decisions, and stacked placement locations.
Review the code, copy it when needed, and add comments before submitting your final version.
zGreen = 30
zRed = 30
# Begin project code
for i in range (6):
arm10.move_to(180, 100, 100)
arm10.set_end_effector_type(Arm.MAGNET)
arm10.move_to(100, 200, 16)
arm10.set_end_effector_magnet(True)
arm10.move_to(100, 200, 75)
arm10.move_to(45, 175, 50)
optical_5.set_light(LedStateType.ON)
optical_5.set_light_power(50, PERCENT)
wait(1, SECONDS)
if optical_5.hue() > 50:
arm10.move_to(175, 0, 100)
arm10.move_to(175, 0, zGreen)
arm10.set_end_effector_magnet(False)
zGreen = zGreen + 10
elif optical_5.hue() < 50:
arm10.move_to(175, 150, 100)
arm10.move_to(175, 150, zRed)
arm10.set_end_effector_magnet(False)
zRed = zRed + 10