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 #179 background imageLoading...
Page #179 background image
Page 198
The rotation sensor code does not work in the March 30, 1999 build of legOS 0.1.7.
Using the Buttons (direct-button.h)
legOS provides one function and some other handy definitions to describe the state of the front panel buttons:
int button_state(void)
This function returns a value that indicates the state of the RCX's four buttons. Use the following macros to interpret the returned value.
PRESSED(state, button)
RELEASED(state, button)
These macros return a boolean value indicating if the specified button was pressed or not. To use these macros, pass the result of button_state() as the state parameter and the name
of a button for button. Buttons names are BUTTON_ONOFF, BUTTON_RUN, BUTTON_VIEW, and BUTTON_PROGRAM.
For example, the following code tests the state of the View button:
if (PRESSED(button_state(), BUTTON_VIEW)) {
// View button is pressed.
}
To test the state of more than one button, it makes sense to store the result of button_state(), like this:
int state;
state = button_state();
if (PRESSED (state, BUTTON_VIEW)) {
// View button is pressed.
}
if (PRESSED(state, BUTTON_PROGRAM) ) {
// Program button is pressed.
}
The Infrared Port (direct-ir.h)
To send data out the IR port, just use the dir_write() function:
size_t dir_write(void const buf, size_t len)
This function writes len bytes of data from the supplied buffer out the IR port. It returns the number of bytes written or -1 if there is an error.

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