adding labels to the displayed values

The previous version of the SoundMachine converted the Tone Frequency value to text and displayed the value. You can improve on this by using a Text block to add more information: Instead of just displaying a number, you’ll display a label and the unit for the value. The unit used to measure frequency is hertz (meaning cycles per second), abbreviated as Hz. Instead of displaying 2500, the program will display Tone: 2500 Hz.

Figure 8-32 and Figure 8-33 show the changes to the program and the Configuration Panel for the Text block. The Tone Frequency value is passed into the Text block as the B value, and the Configuration Panel is used to set the label and unit text. Although you can’t see it in the Configuration ...

Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.