[Computer Science]

[LEGO dacta]

This project idea comes to you from Virtual Ventures in Ottawa, Ontario.

[Virtual Ventures]
[Purpose:]
To create your own robotic device while learning the basics of programming and design.

[Theory:]
[LEGO Interface Box] LEGO dacta is a programmable set of robotic LEGO. These pieces fit easily with regular LEGO but contain special electronic pieces such as touch and light sensors and motors so that you can build robotic devices. Also included are a set computer software and a LEGO interface so that the LEGO creation that has been built can be programmed to do different things.

LEGO dacta sets are very expensive, so this project may be better suited to camps or schools with available resources to buy the equipment.

[Materials:]

[Procedure:]
The LEGO project can be split into 3 major sections: the Building Stage, the Programming Stage, and the Interface Stage.

The Building Stage:
Your LEGO dacta kit will come with instructions to make different devices, but keep in mind that you can build anything you like! You are only limited by the number of pieces you have.

As you build, try to look at specific devices and learn how they work. For example, the touch button is a Boolean switch. It has only two states, true and false. Try plugging it in and dropping the touch icon into the right port and watching the switch toggle back and forth.

Also important is the way electrical parts of the LEGO work. You might want to look through the LEGO manuals to find out more before going on to the next stage.

The Programming Stage:
The first thing you need to learn is how to drag and drop all the icons onto the various input and output devices they have attached. Then you should try to give everything a logical name. For example, the motor that powers the car would be called car_motor. You or anyone else looking at your program could have difficulty figuring out how it works if you've called your motor bobs_brain!

Then try to click the mouse on the icons and experiment with making your devices work. Once you've played with that and decide you'd like to try something new, go to the Command Center and try entering one line commands.

Before you send instructions to any device, you have to tell the computer which device it should send the instructions to. This is done by talking to the device, the same way you would talk to a person. So the code would look like this:

talkto "car_motor

The quotation marks are there to tell the computer that the device name is car_motor.

You should try to experiment with using many of the commands outlined on the Command Sheet. (You may want to print out a copy of this sheet to make it easy to check.) Try setting the power and decreasing the speed of your device. Try reversing directions and learn how to talk to the specific side of a motor to make sure it only goes one way! Look up the onfor and wait commands and figure how they work. Try all of the commands if possible!

Here's an example of a real life situation to illustrate the if statement:

Let's say your room hasn't been cleaned in a month and your Mom says, "If you don't clean your room right now you are grounded!"
What is the condition? (Cleaning your room)
What is the consequence? (Being grounded)

Well, it works the same for programming.
If the touch sensor is true (the switch is pushed 'on') we want the lights to turn on.
What is the condition? (Touch sensor is true)
What is the consequence? (Turn the lights on)

The example code for the last one is if touch [talkto "lamp on]

[Hard at work programming the LEGO]

To get a better understanding of the syntax take a look at the example programs or use the help command in the software .

After this point, you should choose Procedures from the Pages Menu. This is the page where you write your program. Make sure not to write out the entire program in the Command Center one line at a time. There is a big difference between the procedures window and the Command Center: one is for a programming, the other is for line by line command entry.

The program is the hardest part. Before you actually try to write out the program, you might want to write down in detail what the program should do (what you want your device to do) depending on different conditions.

Note that you can have multiple programs in the procedures file. Each program can call another program that was written later on in the procedures file. For example:

To Program1
talkto "car_motor onfor 10
Program2
end

The Interface Stage:
The LEGO software has a unique feature that allows you to build a type of "graphical user interface" for your program and device. Selecting Page1 from the Pages menu will give you the opportunity to add text boxes, buttons, and controls, as well as insert pictures. This way, you get to make a "Presentation" that explains your project in detail to anyone who might like to look at your device.

[Conclusions:]
Playing with LEGO dacta is a fun way to learn a bit about robotics, programming, and even engineering design concepts. If you've enjoyed experimenting with your LEGO dacta, you can try the Shad Valley design challenge. This will allow you to test out your LEGO dacta design skills!

Resources:

[Back]


[Home][Canadian Scientists][Credits][Français]

Physics | Chemistry | Biology | Engineering | Computer Science | Understanding Science and Technology

Produced by Galactics.
Comments: galactics@spacesim.org.
Last updated on 14 August 1998.