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 #178 background imageLoading...
Page #178 background image
Page 197
if (SENSOR_1 < 0xf000) {
// Touch sensor is pressed.
}
If you're working with light or rotation sensors, legOS does offer some help. First, you can set inputs to be active or passive:
void ds_active(unsigned const sensor)
void ds_passive(unsigned const sensor)
Use these functions to set the specified sensor to active or passive mode. The light and rotation sensors are active sensors; the touch and temperature sensors are passive.
The argument to these functions is the address of one of the sensor values. For example, to set input 2 to be active, you would do this:
ds_active(&SENSOR_2);
Processed light sensor values can be retrieved with the following macros:
LIGHT_1
LIGHT_2
LIGHT_3
These macros process raw input values to produce a light sensor reading in the range from 0 to approximately LIGHT_MAX.
legOS also supports rotation sensors with the following functions:
void ds_rotation_on(unsigned const sensor)
void ds_rotation_off(unsigned const sensor)
These functions turn on or off rotation counting for the specified input.
void ds_rotation_set(unsigned const sensor, int pos)
This function sets the current rotation count of the given input.
Once you get the input set up for rotation, you can retrieve the rotation value with one of the following macros:
ROTATION_1
ROTATION_2
ROTATION_3
These macros return the rotation count for each of the inputs.
Setting up input 3 for a rotation sensor, then, looks something like this:
ds_active(&SENSOR_3);
ds_rotation_on(&SENSOR_3);
ds_rotation_set(&SENSOR_3, 0);
To actually read the rotation value, you would just use the ROTATION_3 macro.

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