The input portion of the code is located halfway through the program. The flow of the input sensing follows a fairly simple path. Essentially RoboPele waits for the first sensor to be triggered. After the inital triggering, the timer is reset and RoboPele waits for the second sensor to be triggered.
In order to introduce the inital cart movement before the ball speed is known there was a code segment placed in the middle of the loop which waited for the second sensor. This little segment would activate the cart and stop it after a certain distance was covered. Although it was unneccessary, this initial speed could be set incrementally over time and distance to provide a smoother acceleration. If the outer loop, waiting for the second sensor, exited then RoboPele's cart would continue without stopping.
In addition to the small code segment during the input phase, the main bulk of the control portion of RoboPele's code was a series of check and chose code blocks. Each check and chose would compare the timer to a preset value and set the power levels for the cart's motors. Some of these code segments would also set a delay, in the form of a tone that would prevent the cart from going too early and missing the ball.
Finally, the output code, which is located at the begining of the program, would activate the motors. After a total distance away from the intial position was reached. the motors would stop, change deterection and power up again to return the cart back to where it started from.
The placement of the output code first caused an interesting behaviour to be exhibited. When RoboPele's program is first activated, it initally "sweeps" the arena by advancing to the collision point and returning to its starting point. This behaviour proved most useful when setting up the position of the trough, as it would show exactly where collision was expected to happen.