Not eXactly

The not exactly c ( “not exactly C ” in French) or NXC is a programming language specific to robot Lego Mindstorms NXT -based NBC , an assembly language . The IDE associated with this language is BricxCC .

History

The first version of the NXC dates from 2007, the year of release of the NXT standard under public license Mozilla. Its developer, John Hansen, had already developed the NQC for the RCX ; it also develops the IDE BricxCC .

Until version 1.26 of the microprogram , the use of floating-point numbers was not possible on the NXT because they were not used for motor control and acquisition of sensor measurements. Since this version, this is also possible with the NXC.

Examples of NXC programs

Here are two examples of programs that can be done with the NXC, followed by an explanation of their effect.

Ignition of a motor:

Task main ()
{
 OnFwd ( OUT_A , 75);
 Wait ( 1000 );
}

The actuator connected to the “A” socket of the NXT starts and the program stops after 1 second.

Reaction to light:

Task main ()
{
 SetSensorTouch ( S1 );
 SetSensorLight ( S2 );
 OnFwd ( OUT_A );
 while ( SENSOR_1 == FALSE )
 {
 If ( SENSOR_2 > 50 )
 {
 PlayTone ( 440 , 10 );
 }
 }
}

The actuator connected to the “A” socket of the NXT is started and the type of the sensors 1 and 2 is defined; If the sensor 2 (light sensor) is placed in front of a source of light, the NXT produces a tone (of frequency 440 Hz and therefore a la 3 ) for 10 milliseconds . Pressing sensor 1 (contact sensor) causes the program to stop.

References

  • ( In ) This article is partially or entirely from the article in English entitled ” not exactly c ” ( see the list of authors ) .