“Clearing the Swimming Pool” looks similar to Robot SUMO…. Let us remind ourselves about the previous “C2: Robot SUMO” tutorial Perhaps we could modify our “C2: Robot SUMO” program commands for this “Swimming Pool” challenge Start up our LEGO EV3 program command editor Left-click on “File”, left-click on “Open Project” and choose the name of the C2: SUMO program you saved when doing the C2: playlist tutorials. Go through the “C2: Robot SUMO” playlist tutorials before enjoying these “Swimming Pool” tutorials. Close the “Document Your Work” window so we can see our old “C2: SUMO” program. Click on the “Pan” menu option to change to the “hand” cursor, and left-click on the editor window so we can drag the program to the middle of the editor window Left-click on the “Select” menu option to change the cursor back to an arrow Looking at our old SUMO program… When YayaBot’s color sensor sees black (a reflected light reading less than 38), it… it stops YayaBot, goes backwards one wheel rotation, and spins around half a wheel rotation Our SUMO ring had a thick black line around the SUMO arena, which gave a reflected light reading less than 38 percent. However we do not know the colour of whatever it is surrounding our Swimming Pool, so we can not use the same SUMO program commands… All we can use in our program commands is that our “Swimming Pool” is blue. We can change our Switch commands so that we no longer use reflected light, instead… instead of using a reflected light intensity of 38 (as we did for our SUMO program commands) for the Switch command we can use the blue colour of our Swimming Pool, and send YayaBot forwards when the color sensor on YayaBot sees blue Left-click on the “Color” sensor option, and… and left-click on the “Measure” option, and… and left-click on the “Color” option Notice that the top of the Switch image has changed There is now a black square, left-click on this and select the “blue” option Now, when YayaBot’s color sensor sees “blue”, the top line of the switch command will send YayaBot forwards (at 50 percent both motors) When the color sensor does not see blue, the commands in the lower line of the Switch are supposed to be obeyed, but… but we have left the blue option at the top of the Switch command as “Default”, this is a bad decision. This is why it is a bad choice… What happened was that the Switch command was confused when the color sensor saw the outside of the blue swimming pool, and… and when it was confused it used the “Default” option, which was to act as if all the confusing area outside the Swimming Pool was also blue. and so it kept on going straight ahead even thought it was outside the Swimming Pool, which was not what we wanted… To fix this problem, left-click on the small circle alongside the square in the middle line of the switch, and… and this will make the lower line of the switch the “Default” option. so that if the color sensor is confused, the default will now be to obey the lower Switch command line instructions, and… and stop both motors, go backwards one wheel rotation, and spin around half a wheel rotation… Let us see if the program commands (with the changed default) now help YayaBot clear the Swimming Pool of toys Looks good! Changing the Default was not obvious, but it made a really big difference YayaBot is working beautifully now… But we would also like to be able to start YayaBot from outside the swimming pool. How could we do that? If we wanted to start YayaBot from outside the Swimming Pool, we would need to add a command outside the big loop that surrounds our program commands We would have to place the command immediately after the green triangle Start image, making it the first command for
YayaBot to obey. Make sure the green rectangle is raised, and left-click and drag the “Move Tank” command to the start of the program commands, before the Loop… Change both the Motors to fifty percent power, and the wheel rotations to four, but… but the number of rotations you will need for your Robot will probably be different. Let us download these commands to our EV3 Robot YayaBot, and see if we have taught YayaBot to do what we want to happen… Works beautifully! So pleasing….