Page 129 -
P. 129
243_MasterPieces_02b.qxd 4/18/03 6:59 PM Page 101
The Learning Brick Sorter • Masterpiece 2 101
Move(bin);
OpenHand();
// wait for user input
while (SENSOR_1 <LITE_THRSHLD && SENSOR_2 == 0);
// update knowledge base
if (SENSOR_2 == 1) // wrong
{
PlaySound(SOUND_LOW_BEEP);
Wait(OP_DELAY);
UpdateKnowledgeBase(false);
}
else // right
{
PlaySound(SOUND_DOUBLE_BEEP);
Wait(OP_DELAY);
UpdateKnowledgeBase(true);
};
// go back to pick up station
Move(-1);
}
}
The code requires only a few explanations.The constant OP_DELAY is used as a
short delay during operations: it’s especially important to give pneumatic pistons the time
necessary to complete their stroke before performing further operations. In reading the
touch sensors in the switchbox, one has to consider that SENSOR_1 is connected to the
light sensor too.Thus, every test must compare the reading against LITE_THRSHLD,
instead of simply checking a 1 or 0 as happens for SENSOR_2. Finally, when providing
feedback through the levers in the switchbox, the user receives different sounds for the
positive or negative response.
Training and Using the Learning Brick Sorter
Before switching the Learning Brick Sorter on, check that the hand is open and the arm
is lifted and is positioned over the pickup stand.
Next operate the manual pump: the small pump connected to the motor that rotates
the turntable will maintain the pressure while the Learning Brick Sorter is in action,.
Initially you have to provide pressure in the pneumatic circuit.As the airflow provided by
the motorized pump is slightly inferior to the average air consumption of the Learning

