A Way to Learn Programming in a LOGO-like Language
Nevädzová 2 821 01 Slovakia
tel/fax: (420) 7 5227695,
We introduce some ideas how to use LEGO Dacta computer controlled models in classrooms, what problems can arise and new ideas for building models.
LEGO Dacta, computer-controlled models, creativity
1 Introduction or why shall we talk about "well-known" things
One of the messages of this paper is: a model and a programme is interesting if it is out of order, if it does not work. To find out what is wrong, how to realize an idea is more interesting than build perfect simple models. We will introduce some ideas but no complete solutions. We like non-trivial problems and maybe in this paper you can find some new ideas how to use computer-controlled LEGO in classrooms. The first two chapters are explanatory, the reader who is familiar with the set need not read them.
2 Technical parameters, possibilities
There is a LEGO set called 9701 and a corresponding interface (9751), which is connected to the serial port of the computer. The set consists of sensors, motors, lamps a sound element and many technical LEGO bricks. There are 4 kinds of sensors: a temperature sensor, a light sensor, an angle sensor and a touch sensor. The sampling rate of sensors is about 12 samples per second, the light sensor and the temperature have 10 bit output, the touch sensor is Boolean and the angle sensor reports 16 units for 360 grades, i.e. its sensitivity is 22,5 grades. In the set there are also gears, so this is no restriction. The motors are 9V DC motors with 1400 r/min, and the current is about 100 mA. The interface has 8 output ports (for the motors, lamps etc.) and 8 input ports for the sensors. The input ports are read by the computer and the output ports are controlled by the computer. There are also building instructions (and examples of programmes). All examples in this paper are for the software named Control Lab.
3 Programming: advantages, various levels
Not all children are keen in programming. But most of the children love to see the things move, love to build, create something by their own. The LEGO Dacta gives the possibility to bring together some manual building, the fascination from getting things to move and algorithmitical thinking. The pupils are provoked, motivated to write small programmes which do something and they see immediately the result.
The programmes are modular: the children can
Typical easy programmes:
Traffic light and a car waiting for the green light:
tto "lampa onfor 5 ;red lamp on
tto [lampa lampb] onfor 2 ;red and yellow lamp on
tto [lampc motorh] onfor 5 ;green lamp on and the car begins to move
b) with feedback
Conveyor belt with sound effect when a brick is transported
tto "motora on
loop [waituntil [light5 > 40] tto "soundd on
waituntil [light5 < 38] off]
4 The complexity of the task, the reality
The programmes control real things and we must have some understanding what is happening. It is not a "pure programming". To be more concrete we give some examples.
tto "motora setright on
waituntil [angle5 > 16]
tto "motora off
tto "motora seleft on
waituntil [angle5 < 1]
tto "motora off
loop [if temp1 > 22 [open] if temp1 < 22 [close]]
This is a fragment of a programme for a greenhouse. The door of the greenhouse should be opened when the temperature is high and closed when it is low. But this programme will not work correctly. In the reality the motor is running (in a strange way) even then when the door is already opened. The reason of this strange behaviour is that in the open procedure we at first start the motor and only then check if the door is already opened and every step takes some time.
An other example:
make "a 0
loop [if touch1 [make :a :a + 1 show :a]]
The programme does not count the number of touches, the touch sensor is sampled about 12 times in one second so one touch can imply more impulses.
waituntil [light6 > 40]
ifelse light6 > 45 [show "yellow] [show "blue]
This programme does not distinguish the yellow and blue bricks on a black conveyor belt because of the fact that the a moving yellow brick is for the sensor at the first moment "blue", the sensor reports the average colour in its angle of view.
The physics "behind" is for children hidden and it can be a creative work to find out the reasons, why some programmes are bad. It is good to let the pupils do experiments, let them play and let them invent the "flies in the soup".
5 Some ideas for new models, new programmes
5.1 A laser disc reader
A paper disc slowly rotates and its light-reflection rate is permanently read by the light sensor. The disc is painted and depending on the value reported by the light sensor a tone of certain height is played. Then for every disc you will have a characteristic melody. There are problems with background light, timing, defining the levels for various tones.
5.2 Explorer car, a follow-you car
To invent a car which follows the light source, e.g. follows an other car controlled manually. An other task: the car shall go in a room to thewindow or to the place where the light is most intensive.
5.3 Experiments in physics graphs for temperature, velocity
We have the possibility to let the computer draw graphs derived from values reported by sensors, so we can make our own experiments how the temperature or speed is changing in real processes.
5.4 A smooth feedbacksetting a stable numbers of rotations
Using the project page you set manually the desired number of rotations per second and the the computer shall keep this number of rotation independently from the load of the motor. The problem is not trivial because of only few levels of the instruction setpower.
5.5 Communicationlight controlled cars, wireless communication, coding
We have a light tranceiver and a receiver and the problem is with these means controll some process or communicate, e.g. send and receive text messages. Problems with timing and synchronization can be interesting.