NXT Musical Instrument





Name of Activity NXT Musical Instrument
Author Jay Clark
Keywords Mary Had A Little Lamb, simple song, NXT, switches, sensors, task, instrument, wiring, math blocks, programming, loops, MINDSTORMS, Music Engineering, numerical frequency, audible, pitch, 2 Hours Total
Subject NXTs
Grade Level 4, 5, 6, 7, 8, 9+
Time 2 Hours Total
Brief Description Students will play “Mary Had A Little Lamb” and other simple songs on their NXT using switches and touch sensors. When students complete that task, they will make an instrument using other sensors, requiring wiring and math blocks in their programs.
Lesson Objectives: Learn about loops, switches, and math blocks
Introduce Musical Instrument Engineering
Understand the relationship between numerical frequency and audible pitch
Materials Needed: NXT Kit
Computer with MINDSTORMS NXT software
Necessary Background Mary had a little lamb is a simple song consisting of just three notes. The notes and corresponding lyrics are below:


ma-ry had a lit-tle lamb


lit-tle lamb, lit-tle lamb


mar-y had a lit-tle lamb


whose fleece was white as snow

All musical notes have a corresponding frequency. Concert A (or middle A) is 440 Hz. In order to play mary had a little lamb using a light or distance sensor, you must know the frequencies of the three notes you’re using:

C – 262

D – 294

E – 330


frequency – the rate at which a vibration occurs. Determines the pitch of a note.

Procedure Introduction Introduce switches to the students. A switch is a program structure that makes decisions based on external criteria, such as a sensor value. Introduce the lesson. Show the students the notes of Mary had a little lamb. Ask them how many touch sensors they would need to play it. Guide them to realize that they could use 2, and there are 4 opportunities for notes to play with two touch sensors: Left pressed, right pressed, both pressed, none pressed. Guide them through brainstorming how the program should look. Usually it’s hard for them to see that the second switch is required. ActivityHave the students program their robots to be able to play mary had a little lamb using switch blocks and sound blocks. When they finish, have them use another sensor and wiring and math blocks in their program to create another musical instrument. Or allow them to use switches with another sensor to set up ranges for each note.
Extensions: Play a different song!
Use touch sensors in conjunction with another sensor to set the octave.
Reference 1 http://sites.tufts.edu/stompactivitydatabase/files/formidable/g.png

NXT Segway





Name of Activity NXT Segway
Author Jay Clark
Keywords NXT, balance, wheels, sensors, wiring, math blocks, proportional controllers, light sensor
Subject NXTs
Grade Level 9+
Time 3 Hours Total
Brief Description Students build and program an NXT to balance on only two wheels using two light sensors.
Lesson Objectives: Master the use of wiring and math blocks
Master Building with NXT pieces
Introduce the concept of proportional controllers
Materials Needed: NXT kit plus one additional light sensor for each group.
Computers with LEGO Mindstorms installed.
Preparation and Set Up: Make sure this activity is done in an evenly lit room with a consistently-colored floor. Otherwise, it will not work.
Distribute extra light sensors to each group.
Necessary Background An NXT segway works by separating two light sensors about the center of gravity of the robot. If the robot loses its balance and starts to lean one way, one light sensor will receive more reflected light than the other. The differnce in these values can be scaled and then used to control the motors.

Generally, the following tips allow for the easiest construction of an NXT Segway:

The robot’s center of gravity should be such that the robot’s balancing point allows for the two light sensors to be evenly spaced off the ground.
The further the light sensors are from the robot, the more sensitive the response.
Weight should be added way above the pivot point (the wheels). Think about balancing a broom vs. balancing a watermelon.

Vocabulary: Proportional Controller – Control in which the amount of corrective action is proportional to the amount of error

Procedure Introduce students to the concept of proportional control. examples:

  • slowing down based on distance from stop sign
  • changing dial in shower based on error from desired temperature.

Introduce proportional control in the human brain in the form of keeping balance.

  • If you lean forward a little bit, your brain applies pressure to your toes to try to push your center of gravity back.
  • If you move to far forward, your brain will step forward.
  • If you are leaning way far forward, your brain will call for a very quick, large step.

The reaction is proportional to the error.   Introduce the segway activity. Now that we know how to balance an object that we know is leaning one way or another, we need to determine how we can figure out if the NXT is leaning. Ask students for suggestions. Encourage all ideas, but in the end, tell them that we’re going to use light sensors because they have the most consistent response and resolution. Activity If we mount the light sensors so they are the exact same distance off the ground when the robot is balanced, we can be sure that the light sensors will have the same reading. If the robot starts leaning, there will be a difference in the light sensor readings. We can use that difference to control the motors to balance the robot.Notes Students will have to experimentally determine their constant of proportionality. Because the power input of the move block converts negative numbers into positive numbers, there needs to be a comparison block to set the move block’s direction.

Reference 1 http://sites.tufts.edu/stompactivitydatabase/files/formidable/a3.png
Reference 2 http://sites.tufts.edu/stompactivitydatabase/files/formidable/b4.png

Light Symphony





Name of Activity Light Symphony
Author STOMP
Keywords light sensor, NXT, tone, ambient light, loops, math blocks, sound, inputs, outputs, Engineering Design Process
Subject NXTs
Grade Level 4, 5, 6, 7, 8, 9+
Time 1 Hour Total
Brief Description In this activity, students will wire a light sensor to their NXT bricks. Light sensor data
will be collected and used in a program that plays a tone based on the ambient light
in the room.
Lesson Objectives: - To learn to program using the light sensor, loops, math blocks, and sound.
Materials Needed: - NXT brick.
- Light sensor.
- Computers running MINDSTORMS NXT software.
Preparation and Set Up: Set up computers with MINDSTORMS NXT Software.
Arrange students into groups of two.
Distribute necessary materials.
Necessary Background Vocabulary:
engineering design process
  1. Have students wire a light sensor to their NXT brick. They may or may not want to attach the light sensor to the brick.
  2. Have students program their NXT bricks
    1. The program should collect light sensor data
    2. The program should take this data and multiply it by a number (It may be good to start with about 10, but students can use trial and error until they find a multiple that creates the music box that they want)
    3. This new number should determine the tone of the note that the NXT brick plays.
    4. Students should add a wait for time block so that their note will play for that amount of before the program loops and the brick plays a new note.
  3. To test this program either have students turn their light sensors towards and away from a light source to produce different tones, or change the light levels in the room.
  4. Students may have to modify their program and change the multiple in their math block, or change the amount of time between notes. Allow students to test and retest multiple times.
Extensions: Get students to match the pitch of another NXT brick.
Modifications: - This same activity could be done using the proximity sensor attached to a car.
- Students could program their NXT brick to play a tone depending on how close their car was to an object. This could be related to a safety device that would warn you if your car was going to bump into a wall.
Reference 1 http://sites.tufts.edu/stompactivitydatabase/files/formidable/62_image_1.jpg
Reference 2 http://sites.tufts.edu/stompactivitydatabase/files/formidable/62_image_2.png
Reference 3 http://sites.tufts.edu/stompactivitydatabase/files/formidable/light_symphony.doc

Switch to our mobile site