Skip to main content

Email question from a student


I received an email earlier today from a 7th grade student in Utah. Here's the (edited) question:


"How can I program my robot to make more than 1 yes-or-no decision. I have a robot that looks at 3 different sensors but I'm only using sensor logic values and not numbers. The switch block only lets me do one True or False condition."


Great question! And I certainly understand why you're confused. Rather than email the answer, I figured I'd share this with others because if one person is asking, I'm sure there are others. So, here's one option (option #2 will be provided in a separate blog post):
I don't know the details of your robot, but let's just assume that your robot's 3 sensors are Touch, Sound, and Light. You've configured the trigger values for each sensor (For example, does the Light sensor detect a light value less than 20 - true or false?) and are using the logic data plugs to take the True or False response from each sensor.
You didn't state whether all 3 sensor logic values must all be True or all be False, so this example will show you how to make decision based on a mixture of logic values, okay? Let's look at the possible options that can be returned. I'm going to write down all the possible options that could come from 3 sensors in the following format: Light - Sound - Touch with a 1 indicating True and a 0 indicating False. For example, if the Light sensor is True, the Sound sensor is False, and the Touch sensor is True, then I would write 1 - 0 - 1. Got it?
Okay, next we need to look at all the possible options?


Light - Sound - Touch

0 - 0 - 0

0 - 0 - 1

0 - 1 - 0

0 - 1 - 1

1 - 0 - 0

1 - 0 - 1

1 - 1 - 0

1 - 1 - 1


Verify that I've got them all, but I think you'll find that that's it... I've provided everything from all False to all True and everything in between. Now, count them up. There are a total of 8 possible combinations.
Using this, I need to figure out how to program a decision-making procedure that can account for 8 possible combinations. And to do that, I'm going to use the Switch block that you talked about in your question. You are correct that the Switch block only provides 2 possible options when using a Logic value - True or False. What I think will surprise you is that you can place a Switch block inside a Switch block inside a Switch block. Yes, that's 3 levels deep. By doing this, you can check the status of each sensor, one-at-a-time - based on True or False response, another Switch block will be used to check the status of the next sensor (True or False). A final level of Switch block will be added to test the last sensor.
Take a look at the image I've provided here and you'll see how this is done. Starting from the left, you'll see the first Switch block (SB-1) with True or False path. Follow it and you'll see 2 new SBs (SB-2 and SB-3), one in the True path of SB-1 and one in the False path of SB-1. Follow these and you'll see 4 new SBs, 2 in the True path of SB-2 and 2 in the False path for SB-3. And because each of these SBs have a True/False path, you will find that you have a total of 8 possible paths that can be traced.
If this is confusing you, just trace each possible path with your finger and keep count. Use the circles in the right image to represent each switch - blue lines are True and red lines are False. If you're still confused, the best solution would be to duplicate my image in NXT-G and experiment - it'll make sense if you think about it for a while. Thanks for the question - and option 2 will be posted shortly. In that option, I'm going to show you a way to use logic values to determine if all sensors are True or all sensors are False.
Jim




Light sensor

Sound sensor

Touch sensor

Popular posts from this blog

Celebrating 25 Years of MINDSTORMS

In celebration of the 25th Anniversary of MINDSTORMS, we take a trip through history. Please also visit ROBOTMAK3RS Community every week as we highlight different projects all through 2023 in celebration of the anniversary. Some of the early history is based on the content shared by  Coder Shah  in our  MINDSTORMS EV3 Community Group . Some of the text and links may have been edited from his original posts for consistency and clarity.  1984 - Kjeld Kirk Kristiansen watched a TV program called "Talking Turtle," where MIT professor Seymour Papert demonstrated how children could control robot "turtles" using LOGO, a programming language he developed. 1988 - The collaboration between MIT and LEGO resulted in LEGO TC Logo in 1988, which allowed students to control LEGO models using computer commands. The video shows Papert demonstrating TC Logo. 1990 - LEGO TC Logo was hampered since the robots you built had to be tethered to a personal computer. LEGO and MIT...

ROBOTMAK3RS Review: LEGO River Steamboat

I thought the LEGO River Steamboat would be an interesting set for a ROBOTMAK3R review for a few reasons. First, the LEGO designer of the model is Marina Stampoli, a long-time collaborator of the late ROBOTMAK3R Vassilis Chryssanthakopoulo s. From earlier collaborations with Vassilis, I  knew Marina was incredibly talented, with an eye for aesthetics and functionality. Her background in architecture is particularly useful for her relatively new position at LEGO. Her other sets include the Magic of Disney (21352), Message Board (41839), and Red London Telephone Box (21347). Second, watching Marina's reveal video  and reading her designer interview made this set even more tempting to build. The gearing mechanisms running through the model gave way to many opportunities for automation using LEGO robotics elements. Since ROBOTMAK3RS is all about adding interactivity and automation to LEGO brick, I thought it would be fun to see where and how LEGO robotics could be added to this s...

Part 3: Restoring the LEGO MINDSTORMS Robot Inventor App on Windows

Summary: This blog is written by Sizlaq and is about how he restored the LEGO MINDSTORMS Robot Inventor Windows app using an archived Appx installer and a backup of the app’s downloaded content. Important note: The files linked in this post are external archive downloads for the LEGO MINDSTORMS Robot Inventor app and its related content. LEGO MINDSTORMS, LEGO Education and Robot Inventor are LEGO Group products/trademarks. Use these downloads only where you are legally entitled to do so and only for legitimate preservation, repair, education or personal restore purposes. I do not own the LEGO app or content, and the links are provided as a convenience for people trying to restore a legacy installation. Download and run archived software at your own risk, and scan files before installing them. Why these backups mattered The reason I started looking into this was simple: LEGO had announced that the LEGO MINDSTORMS Robot Inventor apps were being discontinued...