19/10/2017 3:35pm
Our paper "Behaviour-Data Relations Modeling Language For Multi- #Robot Control Algorithms" now available to read!… [LINK]
18/10/2017 2:15pm
LEGO's new Women of NASA kit. Great learning for both kids and adults @LEGOIdeas [LINK] [LINK]
17/10/2017 11:01am
Nice open-call #reserch #fellowships programmes at LMU Munich [LINK]
16/10/2017 3:09pm
#robots that can merge and split their collective architecture (but the article title is preposterous @IEEESpectrum) [LINK]
13/10/2017 1:46pm
RT @MMGiuliani: First demo of our new human-robot interaction setup. Come visit us at @BristolRobotLab to have a look 😀. [LINK]

[NXC UserInteraction Library]

Date: Mar 2012
Tags: robotics :: Mindstorms

Current version: 1.2 :: Follow me on Twitter for updates

The User Interaction (UIn) Library helps you create standard user interfaces (multi-line aligned texts, buttons, menus, etc.) and capture user actions on the NXT Mindstorms brick.

The library works with the intelligent brick buttons and keeps all your sensor ports free for your program to use.

The UIn Library is a single .h file that can be included with your NXC project. It has been tested with NBC version 1.2.1 r4 and requires the NXC extended firmware. Please read the development setup tutorial if you are not sure how to get extended firmware.

Main features

How it works

Download a demo (XCode) project to try out the whole UserInteraction library.

This is an example of using a sliding menu in order to decide which task to exectute. UIn function createSlidingMenu() is called with appropriate arguments and the program waits until user selects an option from the menu. The user choice is then resolved by the calling task. Note that ExitTo(Task newTask) is used in order to close the current task and start a new one. This prevents unpredictable behaviour of the new task when calling UIn and other functions.

#include "UserInteraction.h"

task main() {

    //-- create menu with 2-line option items
    string menuItems[3] = {"First#Option","Second#Option", "Third#Option"};
    int userResponse = createSlidingMenu("Select#an option",menuItems, 0);

    //-- resolve answer from the sliding menu
    switch (userResponse) {
        case 0:
            // Selected 'First Option'
        case 1:
            // Selected 'Second Option'
            // Selected 'Third Option'

task onFirstOption() {}
task onSecondOption() {}
task onThirdOption() {}


Other features

Text drawing functions

Shape-drawing functions

Helper functions

  • int getTextPixelLength (string text_)
  • int getAlignedTextPosition (string text_, UIN_ALIGNMENT alignment_)
  • int normaliseTextXPosition (string text_, int xPosition_)
  • int lastPos(string substr_, string string_)

Math functions

  • int round (float number_)
  • float abs (float number_)


Please comment or email me if you have questions or ideas about new functionality.



Hi Raj, I'm glad you got it sorted, although that is a strange solution as those two macros are defined in the library file itself so you would only add those lines if you wanted to change the values. Anyways, I wish you luck, thanks for downloading the library.
oh, I got it solved by adding following two lines.



my long wish has been answered by your excellent interface library. I'm getting error while compiling your demo code with lot of syntax error.

I'm using Bric Command Center Version 3.3(build in windows xp. I can see that UserInteraction.h does exist on the same directory.

Am I missing anything ?


{Please enable JavaScript in order to post comments}


Robot swarms in action

Watch e-puck robots collect resources and bring them back to base. While the previous simulation work helped us to learn a lot about the...

[read full]

How to compile code for e-puck robots on your computer

Compiling code natively on e-puck robots or cross-compiling on your computer can be very tedious. Luckily, there is a third option:...

[read full]

Coding for tomorrow: Why is good code important?

"Why should I care about how my code is written, as long as it works?" I will argue here that well-structured and well-written code not...

[read full]

How Coding in Python Might Be Bad For You

7 reasons why coding in Python is like writing a really bad essay and getting away with it

[read full]