Paper 2 LEGO Mindstorm

18

Proceedings of CITEE, August 4, 2009

Lego Mindstorms NXT and Its Application to
Determine the Number of People Coming In and
Out
Arya Tandy Hermawan
Information Technology Graduate Program, Sekolah Tinggi Teknik Surabaya
Surabaya 60284, Indonesia
arya@stts.edu

Gunawan
Electrical Engineering Dept., Faculty of Industrial Technology, Institut Teknologi Sepuluh Nopember
Surabaya 60111, Indonesia
admin@hansmichael.com

Tri Kurniawan Wijaya
Computer Science Dept., Sekolah Tinggi Teknik Surabaya
Surabaya 60284, Indonesia
tritritri@stts.edu


Abstract- Lego Mindstorms' product which was released
by Lego could connect the needs of com plete peripheral with
motor and sensor and the complexity which commonly occur
when we built the peripheral ourselves. Through its
innovation, in 2006, Lego released Lego Mindstorms NXT
which has supported several sensors, such as: touch sensor,
light sensor, sound sensor, and ultrasonic sensor. This research
discusses Lego Mindstorms NXT and its application to
determine the number of people coming in and out. Until
present, many people argued that to solve the problem we need
electronic devices and microcontroller programming which
can only be handled by people who experts in that field.
Therefore, we will show in this research that even teenagers
can solve the problem themselves. In order to solve the
problem, NXT Intelligent Brick and an ultrasonic sensor
which can read a distance of the nearest object in front of it
will be used. This paper is structured as follows: introduction
about the hardware and software which is used, problem
analysis, solution and conclusion.

Keywords-Ie go
ultrasonic sensor

mindstorms

I.

nxt,

nxt

applications,

INTRODUCTION

In 1998, Lego released Lego Mindstorms RCX
(hereinafter referred to as RCX), a first generation of Lego
Mindstorms family. RCX consists of electric motors and
sensors, Lego bricks (components that have the form similar
to bricks, can be connected one another to create more

complex forms), and Lego Technic (special form of Lego
bricks to create objects or forms related to engineering field,
for example: wheels, gear, axle, and peg). Together with
other additional components, RCX became the most
successful product throughout the history of the company.
Eight years later, the issue Lego Lego Mindstorms NXT
(hereinafter referred to as NXT) which is the advanced
version of the RCX. NXT can be referred to as the new
RCX, the next generation of Lego Mindstorms family. NXT

ISSN: 2085-6350

was first launched in the United States of America in August
2006 and in the European continent two days later.
II.

LEGO PIECES AND NXT INTELLIGENT BRICK

Hardware (hardware) of the NXT can be categorized
into:



Unit controller: NXT Intelligent Brick



Output device: motor



Input device: sensor



Media communication: Bluetooth

A.

NXT Intelligent Brick
The main component of the Lego Mindstorms NXT is a

controller that can be programmed, usually referred to as
Intelligent Brick. NXT Intelligent Brick offered 32-bit
ARM7 microcontroller with 256K flash memory and 64k of
RAM plus the 8-bit AVR microcontroller with 4K flash and
512B of RAM memory.

On the NXT Intelligent Brick, 4 input port is provided
for connecting sensors that may be required and 3 output
port is provided to connect the motor (see figure 1). On the
NXT also available 4 kinds of buttons (see figure 1). Buttons
on the top are (starting from left to right): left button, enter
button, and the right button. Button at the bottom is the
cancel button. All the buttons are (except the cancel button)
can be programmed, for example: move the robot to the right
if right button is pressed, stop the motor if enter button is
pressed, start left motor if left button is pressed.
In this case, the computer is still needed to do the
programming task. Next, the program should be transferred
from the computer to the NXT intelligent brick with a USB
cable.


Conference on Information Technology and Electrical Engineering (CITEE)

19

Proceedings of CITEE, August 4, 2009

inside. When the touch is released, the tip of the sensor will
return to the original position, the spring inside will also be
released. The way the sensors work is mainly used to detect
whether there is obstruction in front of the robot and to get
an input from the robot operator to run a particular task.

Figure 4. NXT touch sensor

Figure 1. NXT intelligent brick

B.

NXTMotor

NXT set consists of 3 Motor. The size of NXT motor is
quite large, about 3 times of the size of RCX motor. This is
due to the high inner gearing that makes the motors much
more powerful and reliable than the RCX's motor (see figure
2). NXT motor has also been equipped with rotation sensor,
therefore we can know the amount of rotation it has been
traveled. The outside form of NXT motor can be seen in the
figure 3.

2) Light Sensor
NXT Light Sensor is a sensor that enables NXT to "see"
(see figure 5), although it is very limited in this context. This
light sensor measures how light or how dark a light that
come into the sensor. It is presented as a number from 0 to
100. Lower number means lower intensity, higher number
means higher intensity. Unfortunately, this sensor can not
distinguish colors; it can only distinguish light and dark. But
of course if the colors which are wanted to be detected have
a different intensity, we can distinguish them. Examples of
the considerably different light intensity: black and white.

Black has a lower intensity than the white, for example: if a
black paper is detected as 20, then the white paper will
detected higher than 20, say it, 40 (the number shown here
just for example, in fact the number detected may be varied
depend on the condition surrounding the sensor).

Figure 2. Inner gearing ofNXT motor

Figure 5. NXT light sensor

3) Sound Sensor
Sound sensor can be considered as the "ears" of the robot
(see figure 6). The sound sensor can detect both decibels
(dB) and adjusted decibels (dBA):


dB: in detecting standard (unadjusted) decibels, all
sounds are measured with equal sensitivity. Thus,
these sounds may include some that are too high or
too low for the human ear to hear.




dBA: in detecting adjusted decibels, the sensitivity
of the sensor is adapted to the sensitivity of the
human ear. In other words, these are the sounds that
human ears are able to hear.

Figure 3. Outside view ofNXT motor

c.

Sensor
Sensors of the NXT enable the robot to react and give
respond to what happens in surrounding areas. There are 4
types of sensors that are owned by NXT: touch sensor, light
sensor, sound sensor and ultrasonic sensor.
1) Touch Sensor
NXT touch sensor utilizes a spring as the nature of how it
works (see figure 4). When it is being pressed (getting a

touch) the tip of the sensor will also pressed the spring

The sound sensor can measure sound pressure levels up
to 90 dB - about the level of a lawnmower. The sound
sensor readings on the MINDSTORMSTM NXT are
displayed in percent. The lower the percent, the quieter is the

Conference on Information Technology and Electrical Engineering (CITEE)

ISSN: 2085-6350

20

Proceedings of CITEE, August 4, 2009

sound. This list of examples can be used as an approximate
reference:


4-5% is like a silent living room




5-10% would be someone talking some distance
away



10-30% is normal conversation close to the sensor or
music played at a normal level



30-100% are people shouting or music being played
at a high volume

Figure 6. NXT sound sensor

Figure 8. Main interface of Lego Mindstorms NXT software

4) Ultrasonic Sensor
Ultrasonic sensor is a brand new sensor in Mindstorms
family (not exist in previous versions of Mindstorms). The
form of the sensor is designed like human eyes (see figure
7). This unique form could possibly be connected with its
ability to "see" the situation around. Actually, the main
function of the sensor is not to see and understand what the
object in front of it is but only to know the distance of the
nearest object in front (can be measured by inches or
centimeters).

Figure 9. Program blocks
In the figure 9, there are several blocks presented. The
outside block is a loop-forever block (iteration) and the
inside blocks are: loop block for the ultrasonic sensor, motor
block (normally used to run or stop the motor), block loop
for the ultrasonic sensor again, and the last block is a motor
block. To know more clearly what is done by each block, we
should have to click on the block that we want to see, and
the properties of the block can be seen at the bottom of the
screen. For more details please see figure 10.

Figure 7. NXT ultrasonic sensor
III.

LEGO MINDSTORMS NXT SOFTWARE

Like all programmable devices (equipment/devices that
can be programmed) NXT also need a software to do
programming tasks. Without this specific software NXT is
the same as plastic toys and other Lego components - can
not move by it self, can not react to the user input, and can
not respond to the environment. The interface of the
software ofLego Mindstorms NXT can be seen in figure 8.
The program is designed for the drag and drop principle.
All that should be done by user is to put different blocks (for
controlling motors, sensors or making decisions and loops)
on the work space, to set some parameters and to connect the
blocks.

ISSN: 2085-6350

Figure 10. Configuration panel
This software is designed so that even a newbie is able to
understand about the meaning of the program. For example,
here is the explanation for figure 10:


Port A, B, and C (in the top left comer) shows what
port that will be set.



Up arrow, down arrow, and stop symbols show what
the motor(s) should do: moving forward, backward
or stop respectively.



Power (fourth row on the left) shows how fast the
motor(s) will move.

Conference on Information Technology and Electrical Engineering (CITEE)

Proceedings of CITEE, August 4, 2009



Duration (second row on the right) show the
duration of the action. For example: how long the
motor(s) will move forward, or how long the
motor(s) will move backward, or how long the
motor(s) will stop before the next action (executing
the next block).
IV.

21

opening door (see figure 12). Error value on the room that
has an outside-opening door can occur because there is a
possibility that the person only opening the door, but helshe
then decided not to enter the room.

PROBLEM ANALYSIS

The problem that have to be solved in this paper is how
can the number of people who coming in and out of a
particular room is determined. This problem can be divided
into 3 more specific problems:
a.

a)

Determine the number of people who coming in and
out of the room. We can say it as the traffic of the
people in that room.

b.

Determine the number of people who coming in
only.

c.

Determine the number of people who leave the room
only.

Figure 11. Room configuration with an outside-opening door

Before designing the solution, the number of the door in
the room has to be known first. Is it a room which has only
one door or the room which has more than one door?
Design of the solution for the room that has only one
door:


Determine the number of people who going through
(either coming in or out) the door, say it, Sa. Since it
is the only door in the room, therefore Sa is result of
the problem point a above.



If Sb is the result of point band Sc is the result of
point c, then Sb = Sal2 and Se = Sa12. Hence, Sb =
Se. Because the room has only one door, it means
that the people who enter the room will also surely
leave the room through the same door which they
enter before. So that the number of people who enter
and leave the room through that door is certainly the
same.

In order to solve the problem for the room which has
more than one door, the problem solving for point band
point c must be done separately. It is because the people who
enter from a particular door could easily exit from another
door, so that the number of people who enter and exit
through each door is not the same. The results for cases in
point b and point c will be different.

セ|

h\

Figure 12. Room configuration with an inside-opening door

Therefore, for the best result, we highly recommended to
implement the solution below to the room with an outsideopening door. Simply use 1 NXT and 1 ultrasonic sensor.
Figure 13 shows a program solution to solve this problem:

Figure 13. A solution example

Here is the complete algorithm:
1.

Provide a counter variable to count the number of
people.

2.

Wait until the ultrasonic sensor reads an object with
a certain distance (indicates that a person is going
through that door).

3.

Increment the counter variable.

4.

Show the value of the counter variable to the NXT
screen.

The scope of this research is limited only to complete the
problems of the room which has one door only.
V.

b)

IMPLEMENTATION

To solve this problem ultrasonic sensor is used. This
sensor was selected because its ability to read the distance of
an object in front of it. While the use of other sensors such
as: touch sensor, light sensor, and sound sensor are defmitely
not acceptable.
Not only the selection of appropriate sensors, but also the
sensor placement and the characteristics of the room affect
the accuracy of the solution. Implementation on a room with
an outside-opening door (see figure 11) will produce a better
census results accuracy than on a room with an inside-

Solution shown in figure 13 is consists of blocks. That is
the way we do programming using Lego Mindstorms
software. Explanation for each block:


Block-l is used to initialize the counter variable.



Block-2 and block-3 are blocks for ultrasonic
sensors to detect and read a certain distance. Block-2
is used to wait until the ultrasonic sensor read a
value that is less than 50cm. When the ultrasonic

Conference on Information Technology and Electrical Engineering (CITEE)

ISSN: 2085-6350

22

Proceedings of CITEE, August 4, 2009
Figure 16. Setting required for block-5

sensor read a value that is less than 50cm it means
that there is a person going through. Later, in fact,
this value (50) can be changed as needed. Sensor
setting on block-2 can be seen in figure 14. Block-3
is used to wait until the ultrasonic sensor read a
value that is greater than 50 em. We need to define
this block to wait until the person passing by or
completely going through the door. The sensor
setting for block-3 is the same as block-2, except for
the distance. We should set the distance for block-3
become> (greater than) instead of < (less than)



Block 7, 8, and 9 are used for showing the value of
the counter variable to NXT screen. Block-7 is used
to read the variable, block-8 to convert the variable
into string, and block-9 is displayed the converting
variable to NXT screen.



Block-2 until block-9 is placed inside the loopforever block (forever iteration, iteration will stop
when the cancel button is pressed on the NXT).
VI.

In fact, the problem to determine the number of people
who going out or going in a particular room can easily be
implemented using Lego Mindstorms NXT set. With the
Lego Mindstorms NXT Intelligent Brick as the brain, its
sensors as the five senses, and Lego Mindstorms NXT
software as the programming tool, even teenagers could
solve the problem easily. Of course, not only this problem,
but also other problems such as this can be addressed as long
as its implementation using the NXT sensor is still possible.

Distance:



em

Centimeters

Figure 14. Setting ultrasonic sesnor block



CONCLUSION AND FUTURE WORK

Block 4, block-5, and block-6 allows us to increment
the counter variable. Block-4 is used to read the
value of the counter variable, block-5 to add it with
1 (increment), and block-6 is used to write the result
to the counter variable. Figure 15 shows the
configuration of these blocks better (taken from
figure 13 with an appropriate zoom), whereas figure
16 shows the setting required for block-5. CtrPerson
which appear in block-4 and block-6 is the name of
the counter variable. The adding process here is to
add A with B (see figure 15). A is taken from the
counter variable (CtrPerson). And B? B is 1 (see
figure 16). We are allowed to set a constant for B by
clicking the block (block-5) and set it at the
configuration tool (figure 16) at the bottom of the
software interface.

For further development, it is expected that the solution
for the room which has two or more doors can be
implemented. To program NXT, now we can utilize not only
Lego NXT Mindstorms software, but also other
programming language. Currently, NXT has also been
programmed in Java programming language (Lejos) and C
(RobotC). For information about Lejos can be viewed at:
lejos.sourceforge.net / RobotC and information about can be
seen in www.robotc.net.
REFERENCES
[1]

[2]
[3]

[4]
[5]
[6]

[7]

F. Klassner, "A Case Study of Lego Mindstorms Suitability for
Artificial Intelligence and Robotic Courses at the College Level,"
SIGCSE Kentucky, 2002.
B. Ricca, E. Lulis, and D. Bade, "Lego Mindstorms and the Growth
of Critical Thinking," Dominican University, 2006.
R. Pfeifer, "Tutorial for Programming the Lego Mindstorms NXT,"
University of Zurich, Department of Informatics, Artificial
Intelligence, 2007.
O. Bishop, Programming Lego Mindstorms NXT. Massachusetts:
Syngress Publishing, 2008
M. P. Scholz, Advanced NXT The Da Vinci Inventions Book.
California: Apress, 2007.
M. Agullo, D. Carlson, Lego Mindstorms Masterpieces: Building and
Programming Advanced Robots.
Massachusetts:
Syngress
Publishing, 2003.
1. F. Kelly, Lego Mindstorms NXT The Mayan Adventure.
California: Apress, 2006.

M. Gasperi, P. Hurbain, and I. Hurbain, Extreme NXT Extending the
Lego Mindstorms NXT to the Next Level. Berkeley, CA: Apress,
2007.
[9] Constructopedia NXT Kit 9797. Tufts University, Center for
Engineering Educational Outreach, 2007.
[10] D. Benedettelli, Creating Cool Mindstorms NXT Robots. Berkeley,
CA: Apress, 2008.
[8]

Figure 15. Block-4, block-5, and block-6



Operation:

A

ISSN: 2085-6350

o

Addition

Conference on Information Technology and Electrical Engineering (CITEE)