Page 224 - The Unofficial Guide to Lego Mindstorms Robots
P. 224
213
x++;
delay(1000);
return 0;
}
The value shown on the display will be 44 the first time the program is run, but it goes up by one each subsequent time, even
when you turn the RCX off and on again. This interesting property was the source of several bugs in the original LightSeeker.c
program.
If you really want to initialize a variable each time your program is run, you should do it explicitly in the code somewhere, like
this:
#include "conio.h"
int x;
int main(void) {
x = 44;
lcd_int(x);
lcd_refresh();
x++;
delay(1000);
return 0;
}
If you look back at LightSeeker.c, you'll see that all the variable initialization is done explicitly. In general, it should ring a
warning bell in your head when you see variables that are initialized at declaration time.
Online Resources
legOS
legOS
http://www.noga.de/legOS/
This is the official home page of legOS, written by Markus Noga. You can download files, browse the documentation, see
installation instructions, and browse related web pages.
LegOS HOWTO
http://arthurdent.dorm.duke.edu/legos/HOWTO/HOWTO.html
Luis Villa has created a comprehensive set of information about legOS at this site. It covers the tools you'll need, where to get
them, and how to install them. It also talks about programming in legOS and includes useful links to the online
MINDSTORMS community.