Menu Content/Inhalt
Home arrow Product Information arrow cball Sensor arrow NXT-G example program for NXT
NXT-G example program for NXT

The following image shows  simple NXT-G program which reads the strongest sensor and its value and displays them on the lcd screen. 

Image

Before you can start using NXT-G to write programs with the cball you must import the I2C communication blocks. To import these blocks you must have the Dynamic Block Update for NXT-G installed. To install the update and import the I2C block follow these instructions.

  1. You can find the Dynamic Block Update on the LEGO website: NXT Programming Software Update
  2. Follow the instructions on the LEGO website to update your NXT-G software.
  3. Download the ‘IIC Write.zip’, ‘IIC Read.zip’ files from the bottom of this article.
  4. Unzip the IIC Write.zip’ and  ‘IIC Read.zip’ files and remember this location.
  5. Start NXT-G and create a new (blank) program. Choose ‘Tools – Block Import and Export Wizard’, browse to the folder you unzipped the ‘IIC Write.zip’ file into, select the ‘Sensor’ Palette, select (click on) ‘IIC Write’ then Import.
  6. Choose ‘Tools – Block Import and Export Wizard’, browse to the folder you unzipped the ‘IIC Read.zip’ file into, select the ‘Sensor’ Palette, select (click on) ‘IIC Read’ then Import.

You are now ready to load the example cball software into NXT-G. Download the cballnxtg.zip file and unzip. Select the ‘File – Open’ option and browse to the directory where you saved the ‘cballnxtg.rbt’, select this file and select open. Your NXT-G will show the example NXT-G program.

The following image shows the setting in the IIC Read block required to read a value from the cball sensor. The default address 0xC0 is 192 in decimal. The full list of commands can be found in the digital command list.

 Image  

You can also download, unzip and open cballnxtg2.zip which has a more advanced example. This example uses the switch and sound blocks to verbally indicate the strongest sensor.

Files: