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 #48 background imageLoading...
Page #48 background image
Figure 3-4.
Details of Trusty's software
Figure 3-4 also shows the toggle subroutine itself. All it does is examine the value of the counter. If it's 0, then the robot is set to turn left and the counter value is changed to 1. The next time
toggle is called, the robot turns right and the counter value is reset to 0. It's useful to have toggle as a subroutine because it is called from two places in Trusty's program.
Page 48
The Light Sensor
Working with the light sensor can be a little tricky. As measured by the RCX, the light sensor outputs a value from 0 (dark) to 100 (bright). However, the signal generated by the sensor has some
noise in it, which means the value jumps around unpredictably. To use a light sensor effectively, then, you need to figure out what the interesting values are and how to respond to them.
Testing Light Sensor Values
The easiest way to figure out what values your light sensor is generating is to use the RCX's View button. Press View repeatedly until a little arrow appears under the input with the sensor. The
RCX's screen should show the value of the sensor. You can place Trusty so the light sensor is over the line, and then observe the value. Now see what values you get when Trusty is off the line.
You should also try the green area of the Test Pad, and try all the measurements with the room both dark and light. This should give you a good feel for the values that are important.
The View button only works if the input is configured to measure a light sensor. To have the input configured correctly, you'll either have to run a program that sets it up or use the Test Panel, in
the RCX Code section of the RIS software. Click on the appropriate input until the light sensor appears. Then click on the Get Sensor Values button to get the current readings.
The choice of 35 and 40 in Trusty's program is based on my measurements; you may want to adjust these values for your specific conditions.
Don't expect to get the same readings from two different light sensors, even under the same conditions with the same RCX. Always test the values before you use
them in a program.
The Light Sensor Watcher
What's going on with that sensor watcher in Figure 3-3? It's actually two sensor watchers rolled into one. The following pseudocode shows how it works:
if the sensor value is in the range from 0 to 35 (but wasn't previously),
execute the "dark" commands
if the sensor value is in the range from 40 to 100 (but wasn't previously),
execute the "bright" commands

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