General Question

Blobman's avatar

How do you run two tasks at once then get it to start over again in the Lego Robotics program of ROBOLAB?

Asked by Blobman (516points) September 28th, 2007

I’m having trouble running “wait for dark” (so when it senses 40 or above it sings) and “wait for push” (so when it bumps into something it stops turns at a random degree and goes another direction) at th same time. The mission thing is called Botzilla Then I want it to start all over again.

Observing members: 0 Composing members: 0

1 Answer

squigish's avatar

If I’m understanding you correctly, you want to create a program in which the robot simultaneously checks two different sensors (touch and light). If the touch sensor is pushed, it will do some behavior, and then go back to checking both sensors. If the light sensor is triggered, it will do another behavior and then go back to checking both sensors. (note that it is not checking either sensor while it is doing its behavior (singing or turning).

If this is the case, probably the simplest way to do it is without using any wait statements at all. Create a forever loop (or a jump and land, if you’re not using version 2.9), and inside that loop, put two forks (if statements), one for each sensor, in series. It’s important that the false part of the fork (the branch that doesn’t contain your song or dance commands) doesn’t contain any type of wait command. The idea is that the program will rapidly run through each if statement, and if they’re both false, just check them again. That way it can respond appropriately to either stimulus.

If you wanted it to still check the sensors while doing its behavior, you’d have to do something more complicated, either with multiple tasks controlled by containers, or with events. I’d be happy to explain this to you further if you’d like.

I put a short quick and dirty example program here

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther