
void cputc(char c, int pos)
Use this method to display a character at the given position. Valid positions are 0 through 4, where 0 is the right-most position (the single digit at the right of the display) and 4 is the left-most
position.
void cputw(unsigned word)
This function displays the supplied value as four hexadecimal digits.
Page 196
Controlling Outputs (direct-motor.h)
Controlling the outputs with legOS is very easy. All you need to do is give the output a direction and a speed.
void motor_a_dir(MotorDirection dir)
void motor_b_dir(MotorDirection dir)
void motor_c_dir(MotorDirection dir)
These functions set the direction of the RCX's outputs. The
dir
value can be
fwd
,
rev
,
brake
, and
off
. The
off
mode is the same as
Float()
in NQC.
∗
void motor_a_speed(unsigned char speed)
void motor_b_speed(unsigned char speed)
void motor_c_speed(unsigned char speed)
These functions set the speed for the outputs. Of course, the speed only really matters when the output direction is
fwd
or
rev
. Values range from 0 to 255. You can use the handy constants
MIN_SPEED
and
MAX_SPEED
if you wish.
To set outputs A and C running forward at top speed, do this:
motor_a_dir(fwd);
motor_c_dir(fwd);
motor_a_speed(MAX_SPEED);
motor_c_speed(MAX_SPEED);
Working with Inputs (direct-sensor.h)
In legOS, support for inputs is rudimentary. Remember all that nice input value processing in NQC and pbFORTH? In legOS, you have to deal with the raw input values, except for light and
rotation sensors. The following macros return the raw value of the inputs:
SENSOR_1
SENSOR_2
SENSOR_3
BATTERY
Use these macros to retrieve the raw value of the corresponding input.
BATTERY
returns an indication of the battery level. The raw values are in the range from 0x0000 to 0xffff.
Don't expect sensors to use the full range of raw input values. You might think a touch sensor would produce a value of 0x0000 when it's pressed and 0xffff when it's not pressed, but the actual
values are not as extreme. The rule of thumb for testing touch sensors is to test if the value falls below 0xF000, like this:
∗
If you're accustomed to working with NQC, don't get confused here:
off
in legOS is the same as
Float()
in NQC, while
brake
in legOS is the same as
Off()
in NQC.
Содержание MINDSTORMS Robots
Страница 22: ...Page 18 The back tread wheels are anchored to the shafts with the 16t gears ...
Страница 23: ...Page 19 Page 20 Next start building support for the drive motors ...
Страница 25: ...Page 22 Attach the motor wires to output A and output C Next build the platform for the front bumpers ...
Страница 26: ...Page 23 The touch sensors are attached only by the shaft that runs through them ...
Страница 41: ...Page 41 ...
Страница 43: ...Next build the support for the light sensor ...
Страница 80: ...Page 85 Make sure the bump on the long pin is up against the 4u beam ...
Страница 82: ......
Страница 84: ...Page 89 ...
Страница 85: ...Step 14 is similar to Step 11 take a deep breath and go slowly ...
Страница 86: ...Page 90 Grabber Arm In Step 17 the half bushings go between the center block and the cams pear shaped pieces ...
Страница 87: ...Page 91 ...
Страница 88: ...Page 92 Make sure that the two sides are at the same angle They should mirror each other ...
Страница 89: ...Page 93 Page 94 ...
Страница 90: ...Structural Support Page 95 ...
Страница 91: ...Idler Wheel Page 96 ...
Страница 92: ...Page 97 Drive Motor ...
Страница 93: ...While you re putting the motor in hold on to the worm gear so it doesn t slip off Page 98 ...
Страница 94: ...Grabber Arm Motor ...
Страница 95: ...Page 99 ...
Страница 96: ...Page 100 RCX Attach the RCX on both sides as shown Page 101 ...
Страница 158: ......
Страница 159: ...Page 175 The 16t gears are nestled inside the tread wheels ...
Страница 160: ...Page 176 ...
Страница 161: ...Page 177 Attach the motors to output A and output C as shown Page 178 ...
Страница 162: ...The light sensor which is mounted on the bumper is attached to input 2 The touch sensor goes on input 1 Page 179 ...