nqc / bricxcc brief introduction david schilling
TRANSCRIPT
![Page 1: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/1.jpg)
NQC / BricxCC
Brief Introduction
David Schilling
![Page 2: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/2.jpg)
BricxCC
Graphical user interface to programming your RCX
![Page 3: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/3.jpg)
BricxCC
EditorSyntax highlightingProgramming helpsCommunication with RCX
![Page 4: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/4.jpg)
F1 – Help
![Page 5: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/5.jpg)
F1 – Help
![Page 6: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/6.jpg)
Templates
![Page 7: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/7.jpg)
Templates
Just click on a command in the template and the function is inserted into the editor with hints for its parametersPress F10 to go to the next one
![Page 8: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/8.jpg)
Communicating with the RCX
![Page 9: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/9.jpg)
NQC
Programming language with C-like syntaxUses Lego’s RCX firmware
![Page 10: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/10.jpg)
Program skeleton
task main() { // your program goes here }
![Page 11: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/11.jpg)
Defining Sensors
SetSensor( SENSOR_1, SENSOR_TOUCH );
SENSOR_TOUCHSENSOR_LIGHTSENSOR_ROTATION
(plus a few rarely used others)
![Page 12: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/12.jpg)
Getting a Sensor’s value
First define a variable
int x;
Then assign the value to that variable
x = SENSOR_1;
![Page 13: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/13.jpg)
Testing a Sensor’s value
Alternatively you can just use the sensor value in an expression
if( SENSOR_1 > 50 ) { }
![Page 14: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/14.jpg)
Sensor Ranges
Sensor type Range
SENSOR_TOUCH true / false
SENSOR_LIGHT0-100 advertised45-70 is normal
SENSOR_ROTATION any integer value
![Page 15: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/15.jpg)
Using Names for Sensors
Early in your program define a nameUse that name instead of the sensor #
Benefits can easily move sensor to a different
port by only making one change code becomes more self-explanatory
![Page 16: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/16.jpg)
Sensor Naming example
#define Bumper SENSOR_1#define Edge SENSOR_2
task main() { SetSensor( Bumper, SENSOR_TOUCH
); SetSensor( Edge, SENSOR_LIGHT ); }
![Page 17: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/17.jpg)
Using Raw Values
With “SetSensor”, The light sensor range(a ‘percentage’ from 0 to 100) is very limitedUsually you’ll only get a value from around45 to 70 or soTo get a greater range, use SetSensorType and SetSensorMode
SetSensorType(SENSOR_1, SENSOR_TYPE_LIGHT );SetSensorMode(SENSOR_1, SENSOR_MODE_RAW );
![Page 18: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/18.jpg)
Raw Sensor Values
The range changes to something like 600 – 800
However, light and dark are reversed: A dark reading of 40 becomes 800 A light reading of 70 becomes 600
![Page 19: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/19.jpg)
Motors
Default names for motors are OUT_A, OUT_B and OUT_CMotor state can be ON, OFF, or FLOATMotor direction and power can be setJust like with sensors, I recommend giving motors names
![Page 20: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/20.jpg)
Motor Commands
You can just use motors (since all motors are identical to the RCX there is no need to define them like sensors)
eg: On( OUT_A );You can combine multiple motors in a command by using the “+” sign
eg: Off( OUT_A+OUT_C );
![Page 21: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/21.jpg)
Motor Commands
Common Commands: On(); Off(); Float(); SetPower(); Fwd(); Rev(); SetDirection(); OnFwd(); OnRev(); OnFor();
![Page 22: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/22.jpg)
Motor States
The following functions just take one or more motors as an argument: On(); - Turns motor on Off(); - Brakes motor Float(); - Lets motor float
![Page 23: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/23.jpg)
Motor Power
To set a motor’s power level use SetPower( OUT_A, OUT_FULL );
The first argument is one or more motorsThe second argument is the power level OUT_LOW, OUT_HALF, OUT_FULL or 0 to 7
![Page 24: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/24.jpg)
Motor Direction
To set a motor’s direction use SetDirection( OUT_A, OUT_FWD );
The first argument is one or more motorsThe second argument is the direction OUT_FWD, or OUT_REV
![Page 25: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/25.jpg)
Motor Direction
A simpler way to set a motor’s direction is to use:
Fwd( OUT_A ); or Rev( OUT_A );
These work the same as SetDirection();You can also use Toggle( OUT_A ); to change the motor’s direction
![Page 26: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/26.jpg)
Changing a Motor’s Orientation
You can rotate the wire 180 degreesYou can change every line in your program that references a motor, orYou can use SetGlobalDirection();
If your motor goes forward when you want it to go reverse, and vice versa, there are a couple of solutions:
![Page 27: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/27.jpg)
SetGlobalDirection();
SetGlobalDirection( OUT_A, OUT_REV );
This command will change a motor’s direction from now on, so that “FWD” means “REV” and vice versa“OUT_FWD” as the second argument restores a motor back to normalThis is a very clean way to write your programs: “FWD” means forward
![Page 28: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/28.jpg)
Motor Example#define Left OUT_A#define Right OUT_C
task main() { SetPower( Left+Right, OUT_FULL ); SetDirection( Left+Right, OUT_FWD ); On( Left+Right ); Wait( 100 ); }
![Page 29: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/29.jpg)
Simple Sumo demo program
(This is a terrible program! I’m just using it to illustrate the concepts covered in this presentation)
![Page 30: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/30.jpg)
// Simple Sumo demo program
#define Bumper SENSOR_1
#define Edge SENSOR_2
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
Naming sensors and motors
![Page 31: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/31.jpg)
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
Setting up sensors and motors
![Page 32: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/32.jpg)
Program loop On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
![Page 33: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/33.jpg)
Complete Program...
![Page 34: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/34.jpg)
// Simple Sumo demo program
#define Bumper SENSOR_1
#define Edge SENSOR_2
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
![Page 35: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/35.jpg)
#define Bumper SENSOR_1
#define Edge SENSOR_2
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
![Page 36: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/36.jpg)
#define Edge SENSOR_2
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
![Page 37: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/37.jpg)
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
![Page 38: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/38.jpg)
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
![Page 39: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/39.jpg)
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
![Page 40: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/40.jpg)
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
![Page 41: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/41.jpg)
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
![Page 42: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/42.jpg)
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
![Page 43: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/43.jpg)
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
![Page 44: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/44.jpg)
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
![Page 45: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/45.jpg)
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
![Page 46: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/46.jpg)
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
![Page 47: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/47.jpg)
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
![Page 48: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/48.jpg)
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
![Page 49: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/49.jpg)
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
![Page 50: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/50.jpg)
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
![Page 51: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/51.jpg)
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
![Page 52: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/52.jpg)
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
![Page 53: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/53.jpg)
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
![Page 54: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/54.jpg)
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
![Page 55: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/55.jpg)
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
![Page 56: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/56.jpg)
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
![Page 57: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/57.jpg)
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
![Page 58: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/58.jpg)
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
![Page 59: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/59.jpg)
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 60: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/60.jpg)
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 61: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/61.jpg)
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 62: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/62.jpg)
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 63: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/63.jpg)
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 64: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/64.jpg)
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 65: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/65.jpg)
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}
![Page 66: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/66.jpg)
![Page 67: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/67.jpg)
![Page 68: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/68.jpg)
![Page 69: NQC / BricxCC Brief Introduction David Schilling](https://reader036.vdocument.in/reader036/viewer/2022062410/5697bf981a28abf838c91276/html5/thumbnails/69.jpg)
// Simple Sumo demo program
#define Bumper SENSOR_1
#define Edge SENSOR_2
#define Left OUT_A
#define Right OUT_C
#define Both OUT_A+OUT_C
task main()
{
SetSensor( Bumper, SENSOR_TOUCH);
SetSensorType( Edge, SENSOR_TYPE_LIGHT );
SetSensorMode( Edge, SENSOR_MODE_RAW );
SetGlobalDirection( Left, OUT_REV );
SetPower( Both, OUT_HALF );
SetDirection( Both, OUT_FWD );
On( Both );
while( true )
{
if( Bumper )
SetPower( Both, OUT_FULL );
else
SetPower( Both, OUT_HALF );
if( Edge > 750 ) // at edge
{
Rev( Both );
Wait( 100 );
Fwd( Left );
Wait( 200 );
Fwd( Right );
}
}
}