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 #99 background imageLoading...
Page #99 background image
Page 103
Programming
Minerva's basic program is straightforward:
find something to pick up
bring it back to the starting point
The program assumes that the objects to pick up will be dark and that the surface Minerva is driving on is light. To return to the starting point, Minerva measures how long it has to drive forward
to pick something up. Then it turns around and drives back for the same amount of time. Here's a slightly exploded version of Minerva's program:
drive forward until the light sensor sees something dark
pick it up with the grabber
turn around
drive back to the starting point
drop whatever's in the grabber
I've written Minerva's program in NQC (see Chapter 4, Not Quite C). You could create a program in RCX Code (the environment that comes with RIS), but you wouldn't be able to implement
some key features. In particular, Minerva's ability to drive back just as far as she drove forward is crucial. There's no way to do this in RCX Code. Minerva's program also does some sensor
calibration that would also be impossible in RCX Code.
Here's the whole program:
#define TURNAROUND_TIME 425
int i;
task main() {
// Arm limit sensor and grabber light sensor.
SetSensor(SENSOR_3, SENSOR_LIGHT);
SetPower(OUT_A + OUT_C, OUT_FULL);
calibrate() ;
i = 0;
while (i < 5) {
retrieve();
i += 1;
}
OFF(OUT_A + OUT_C);
}
#define NUMBER_OF_SAMPLES 10
int runningTotal;
int threshold;

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