EasyManuals Logo

LEGO MINDSTORMS Robots User Manual

LEGO MINDSTORMS Robots
226 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #175 background imageLoading...
Page #175 background image
Page 193
your source code. For example, if you saved the source code above in a file called /projects/HellolegOS.cyou would edit the Makefile's TARGET like this:
TARGET=/projects/HellolegOS
Then type make at the command line. If everything is installed correctly, you'll end up with a HellolegOS.srec file in the same directory as the source file.
Trouble with Make
If you can't make HellolegOS.c, and you're starting to curse at your computer, take a deep
breath. legOS has a strong online community; people will help if you ask. The "Online
Resources" section of this chapter has pointers to helpful sites. One of the best things you
can do is look at LUGNET,
http://www.lugnet.com/, and search through the discussion
group archives for the particular problem you're having. There are at least as many
messages about configuring the legOS development tools as there are about actually
programming in legOS.
If you're using one of the online compilers,just copy the source into the web page and press the compile button. If there are no errors, you will get back an .srec file representing your compiled
legOS program.
Regardless of how the source file is compiled, you will then need to download the .srec file to the RCX, using either nqc or firmdl.
When the download is complete, your RCX will display the string "legOS" to indicate that legOS is running. To actually run the program you just wrote, press the Run button. The display will
show "Hello" for a second or so, then show two zeros. The left number shows the result returned from our main() function. Control has now returned to legOS; you can use the On-Off button
to switch the RCX off and on. When the RCX is on, you can press Run again to see the "Hello'' message again. Show your friends and family; they will be awed and inspired.
Function Reference
Once you've seen one RCX development environment, you've seen them all—to some degree, at least. If you've been reading through this book in order, you've probably noticed that NQC and
pbFORTH have similar commands but different syntax. Likewise, legOS has a set of functions that looks a lot like pbFORTH and
Make sure you've edited Makefile.common. The TOOLPREFIX and LEGOS_ROOT lines should point to the appropriate directories on your system, as described in the comments. Make sure you put
a trailing slash on the
LEGOS_ROOT directory.
Page 194
NQC, but the syntax and usage is slightly different. In this section, I'll describe the important functions of legOS and demonstrate how they are used.
There are, of course, different levels at which you can use legOS. I'll describe the "user-level" functions, meaning the functions you can call without knowing much about what's inside legOS. If
you're looking for even more power, the full source code of legOS is freely available; you can read it, debug it, or reprogram it as much as you'd like.
Using the Display
legOS is surprisingly capable when it comes to managing the display on the RCX. Aside from just displaying numbers, you can ask legOS to approximate a text string using the display, as we did
in the HellolegOS.c example.
Numbers and symbols (rom/lcd.h)
Most of the useful display functions are defined in rom/lcd.h. The first function you should learn is lcd_refresh():
void lcd_refresh(void)
This is the function that makes it all happen. After you call any other display function, you must call lcd_refresh(): to actually update the display.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the LEGO MINDSTORMS Robots and is the answer not in the manual?

LEGO MINDSTORMS Robots Specifications

General IconGeneral
Product LineLEGO MINDSTORMS
CategoryToy
Age Range10+
Batteries RequiredYes
Memory64 MB RAM, 16 MB Flash
ConnectivityBluetooth, USB
SensorsTouch, Color, Gyro
Battery TypeAA
Interactive FeaturesProgrammable, Remote Control
App CompatibilityiOS, Android
ProcessorARM9
Pieces Count601
Battery Count6
App NameLEGO MINDSTORMS EV3 Programmer App

Related product manuals