Lawrence Technological University
College of Arts and Science
Department of Mathematics and Computer Sciences

### Mathematical Experimenting with LEGO Mindstorms

This is a series of exercises you might use to apply the LEGO Mindstorms kit to a mathematics class or an after-school program. These handouts are intended both for teachers and students.

As with all the series in these handout pages, I will add to it as time permits and your suggestions and submissions are most welcome.

If you are new to using this kit as an educational platform, you might want to also look at the handout on short sessions with LEGO Mindstorms for day camps.

• To explore the addition and subtraction of the small natural numbers between -7 and 7, build a wheeled robot with a separate motor for each of two driving wheels. When the right side motor is turning forward faster than the left side motor, the robot will drive in a circle counterclockwise. The bigger the difference in speeds, the smaller the circle. If you use NQC, it will help to do something like
```#define Speed_1 0
#define Speed_2 1
#define Speed_3 2
#define Speed_4 3
#define Speed_5 4
#define Speed_6 5
#define Speed_7 6
#define Speed_8 7
```
Then speed 0 would be with that motor off. The negative speeds are the same as the positive speeds with that motor's direction reversed. Consider several situations:
```Right 7 + Left  3 = ?
Right 7 + Left  5 = ?
Right 7 + Left  0 = ?
Right 3 + Left  0 = ?
Right 3 + Left -3 = ?
Right 3 + Left -7 = ?
```
• After exploring the small natural numbers as above, it would be interesting to consider differences in the behavior of the robot between what is observed and what is predicted with geometry and arithmetic. Try situations like:
```Right 7 + Left  3 = ?
Right 4 + Left  0 = ?
and
Right 6 + Left  0 = ?
Right 3 + Left -3 = ?
```
Friction and physical differences between pairs of motors are easy answers. Calculating the diameter of a circle from the circumference, time × (speedright − speedleft), is also easy when both driving wheels are the same distance from the center of the circle. Which of these cases should work with this calculation?
• Introduce the binary number system. Mount two touch sensors side by side and connect them to the LEGO RCX Brick with long wires. Use this "code reader" to read the code in two sets of LEGO beams that are either 1 or 2 beams thick. The possible codes are then
```0 0
0 1
1 0
1 1
```
Under what conditions are 0 1 and 1 0 different? Use the Awfully Small Code for Information Interchange to show the correct symbol on the Brick display.
CodeSymbol
0 0A
0 1b
1 0c
1 1d
• Reuse the wheeled robot with 2 drive wheels. Add a felt tip marker taped to the robot and some paper to draw on. Then, starting with a triangle, consider consider polygons as sequences of straight lines and turns. Does the sum of the enclosed angles or the sum of the turns equal 360 degrees? Consider a non Euclidean definition of a circle as a limit of a polygon where the number of sides increases and the length of the sides decreases. The pentagon drawn by this fragment of Logo has sharp corners.
```? to polygon :side_length :sides
> repeat :sides [forward :side_length right 360 / :sides ]
> end
polygon defined
? polygon 20 5
```
What modifications are needed, if any, to avoid rounded corners when drawing with your robot?
• Three exercises in event counting with sensors
1. Press a touch sensor with a finger repeatedly and rapidly. Count the presses with the RCX. Discuss "contact bounce" and any differences between the manual and computer count.
2. With a passive light sensor pointed at a light bulb, count flashes with the RCX. Discuss thresholds and sensors.
3. Attach a light sensor pointed down to the wheeled robot. Then count the number of black lines the robot crosses. Discuss edge detection and hysteresis.

Revised August 28, 2005