This post will show you how to download and install the HiTechnic Sensor Blocks for use with the LEGO Mindstorms software. It will also give you a brief tutorial on using the sensor blocks as well as how to access the online help from within the LEGO Mindstorms software.
Before you can use a HiTechnic sensor with the LEGO software, you will need to download and install the sensor block that goes along with the sensor that you are using. To do that, first go to the HiTechnic Downloads page and then click on the category Mindstorms NXT-G Programming Blocks.
Here you will find all the Sensor Blocks that are available for NXT-G, which is the LEGO Mindstorms Software programming language. You will typically find one sensor block per sensor but a few sensors have multiple blocks. You will also find the sensor blocks for the LEGO Light, Sound, Touch and Ultrasonic sensors for use with the HiTechnic Sensor Multiplexer.
If you have the LEGO Mindstorms 1.0 software, then you will need to install a patch called Dynamic Block Update in order to import blocks into the LEGO software, this is not needed with 1.1 or 2.0. You can find Dynamic Block Update on this LEGO Education Downloads page.
Block Download and Installation Instructions
These instructions are for Microsoft Windows operating systems. If you have a Mac, the basic process will be the same.
- To make it easy to install the blocks into the LEGO software, I recommend that you start of by creating a new folder on the Desktop and call it “NXT-G Blocks”. So start of by right-clicking on the Desktop and then select New > Folder. Enter the name “NXT-G Blocks”.
- Now go back to the HiTechnic downloads page and find the file that you want to download. For this example I will download the block for the Acceleration Sensor. Click on Download Now for the sensor block that you are downloading.
- The next page you will see will look like this:
On this page you can enter your name and email address so that we can contact you if necessary. This is optional. When you are ready to proceed, click on Proceed to Download.
- On the next page, click on the filename of the download. For example, for the Acceleration sensor the filename will be: 245-Acceleration_Sensor.zip. In Windows this will open a dialog asking if you want to Open or Save the file, Select Open.
- Now you will want to copy the folder from inside the zip file to the “NXT-G Blocks” folder that you created on the Desktop. Arrange the windows on your screen so that you drag from one file folder window to the other and then drag the folder, in my case “Acceleration Sensor”, from inside the zip file to the “NXT-G Blocks folder”.
Note: You only need to copy the folder, you don’t need to copy the License and ReadMe files. If you want to look at these files then this is a good time to do so. When you have finished this step, you can close the temporary zip file folder.
- Now you are ready to import the block into the LEGO Mindstorms Software. Start the software then find the Block Import/Export Wizard on the Tools menu. On the Block Import/Export Window, there are several steps you will see below.
- Click on Browse and select the “NXT-G Blocks” folder on the Desktop. It should be easy to find.
- In the list box you will see all the NXT-G blocks available in the folder, select the ones you are ready to import.
- Click on the Import button. Note, at this point there may be some warnings that some files already exist. Just click OK on these warnings.
You are done! The new HiTechnic Sensor block is ready to use.
Using the Sensor Blocks
Now that you have the sensor block installed, how do you use it? Of course, that depends a lot on the sensor and what your robot is supposed to do. Here I will show you how to make a really simple program to view the sensor value. Something like this will work for nearly all the sensors and is a very useful way to start using a new sensor since it makes it easy to tell what kind of sensor data your robot is getting.
Start of by creating a new program and name it “ViewSensorName“. In my case I will name it “ViewAccel” since I will be making an Acceleration Sensor View program.
- Your program will consist on a Loop, so start by placing a Loop in your program.
- Inside the loop, put the sensor block for the sensor that you want to view, in my case I will put the Acceleration Sensor block. You will find the HiTechnic sensor blocks on the Advanced Palette.
- Next, add Number To Text block right after the sensor block inside the loop.
- Add Text block right after that still inside the loop. This block will serve a couple of purposes that I will explain later.
- Add a Display block to the loop.
- Finally, add a Wait block to be the last block in your loop. Right now your program should look like this:
Now we need to configure all the blocks as well as add wires. I like to work from right to left when I do this so that is what I will do in this tutorial.
- Start of by clicking on the Wait block. This block will control how fast our loop is; we want it fast but not too fast. If it is too fast then the number may change so rapidly that it is hard to read. In the configuration panel, change the Control: to Time and then change the Seconds to 0.1. This will make the loop repeat about 10 times per second. The configuration panel should look like this:
- Next go to the Display block. Change the Action: to Text. Clear the check-box to Clear the screen (this will make it easier to extend the program to display more stuff). In the Position, change the Line to 1. It should look like this:
- Now it is time to add the data wires. Click on the tab at the lower edge of the Text block and the Display block to fully open their data hub.
Add the following wires by dragging the mouse from one data plug to another.
|Sensor value of the sensor block.||Number input on Number to Text block.|
|The Text output from the Number to Text block.||B input of Text block.|
|The Text output from the Text block.||Text input on Display block.|
- If you make a mistake, you can Edit>Undo (Ctrl-Z) to undo your last change.
- If you need to remove or replace a wire, you can carefully select the wire by clicking on it and then deleting it with the Delete button. When you do this make sure that no block is also selected.
- Sometimes it is easier to wire from right to left, so if you have difficulties making the wire connect in one direction, try to wire it from the other direction.
- You can adjust wires by dragging on the edge of a wire and moving it.
- Another way to fix wires that don’t look right is to click on the data hub tab on the lower edge of some of the blocks. This will make the LEGO software attempt to automatically adjust the wires that are affected by the data hub opening and closing.
- Take your time! The LEGO Software seems to work better if you don’t rush it.
You are done! Now download it to your NXT and give it a try.
This program is easy to extend if you want to display more things on the screen. For example, if you want to display the y and z axis of the Acceleration Sensor as well, just copy-paste the Number to Text, Text, and Display blocks and have two more copies of these blocks in your program. Make sure that the new Display blocks output is on different lines on the screen and update the labels for the other two axis. Then wire the y and z values from the sensor blocks to the new Number to Text blocks.
Getting more help on the HiTechnic Sensor Blocks
Did you know that there is a help file available for all the LEGO and HiTechnic blocks? To see the help file for a block, hover the mouse over the block in the program until the context help information shows up in the lower right corner of the LEGO Mindstorms screen. Then click on “More Help >” to see the full help file. The help file will not only give you more information on the sensor, explain all the inputs and outputs, as well as give additional wiring information.