Programacion nxc

Solo disponible en BuenasTareas
  • Páginas : 48 (11803 palabras )
  • Descarga(s) : 0
  • Publicado : 26 de enero de 2012
Leer documento completo
Vista previa del texto
LEGO NXT Robots using NXC
(beta 30 or higher)
(Version 2.2, June 7, 2007)

by Daniele Benedettelli
with revisions by John Hansen

As happened for good old Mindstorms RIS, CyberMaster, and Spybotics, to unleash the full power of Mindstorms NXT brick, you need a programming environment that is more handy than NXT-G, the National Instruments Labview-like graphicallanguage that comes with NXT retail set. NXC is a programming language, invented by John Hansen, which was especially designed for the Lego robots. If you have never written a program before, don't worry. NXC is really easy to use and this tutorial will lead you on your first steps towards it. To make writing programs even easier, there is the Bricx Command Center (BricxCC). This utility helps you towrite your programs, to download them to the robot, to start and stop them, browse NXT flash memory, convert sound files for use with the brick, and much more. BricxCC works almost like a text processor, but with some extras. This tutorial will use BricxCC (version or higher) as integrated development environment (IDE). You can download it for free from the web at the address BricxCC runs on Windows PCs (95, 98, ME, NT, 2K, XP, Vista). The NXC language can also be used on other platforms. You can download it from the web page Most of this tutorial should also apply to other platforms, except that you loose some of the tools included in BricxCC and the color-coding. The tutorial has been updated to work withbeta 30 of NXC and higher versions. Some of the sample programs will not compile with versions older than beta 30. As side note, my webpage is full of Lego Mindstorms RCX and NXT related content, including a PC tool to communicate with NXT:

Many thanks go to John Hansen, whose work is priceless!



_______ 2
Acknowledgements ____________________________________________________________

________ 2

Contents ____________________________________________________________

______ 3 I. Writing your first program __________________________________________________ 5
Building a robot ______________________________________________________________________ Starting Bricx Command Center __________________________________________________________ Writing the program ____________________________________________________________

_______ Running the program ____________________________________________________________

______ Errors in your program ____________________________________________________________

_____ Changing the speed____________________________________________________________

________ Summary ____________________________________________________________

________________ Making turns ____________________________________________________________

____________ Repeating commands ____________________________________________________________

_____ Adding comments____________________________________________________________

________ Summary ____________________________________________________________

_______________ 5 5 6 7 8 8 9

II. A more interesting program _______________________________________________ 10
10 10 11 12

III. Using variables___________________________________________________

______ 13
Moving in a spiral ____________________________________________________________________ 13 Random numbers ____________________________________________________________

________ 14 Summary ____________________________________________________________

_______________ 15

IV. Control structures__________________________________________________

_____ 16
The if statement___________________________________________________

___________________ 16 The do statement...
tracking img