Let's code the robot to dispense candies based on different colors of LEGO brick detected
Take three different-colored LEGO bricks—blue, green, and yellow. Now, through trial and error, find out the number of rotations needed by the motor to dispense one piece of candy, and note it here:
Rotations of port C = ________
Activity #1
Write a program to dispense one piece of candy when the color sensor senses a yellow brick. Display Yellow Brick Detected before dispensing. Once the candy is dispensed, display One Candy Dispensed, as illustrated in the following screenshot:
Let's move on to the next activity, to add different dispensing actions to the robot for different colors detected.
Activity #2
Write a program to dispense two pieces of candy when the color sensor senses a blue brick. Display Blue Brick Detected before dispensing. Once the candy is dispensed, display Two Candies Dispensed.