VexIQ Sumobot Adventures

I have only just started playing with the VEXIQ system and have discovered some interesting issues. I have previously had to account for the clock cycle of the ‘brain’ and how block code is compiled when using LEGO and Makecode. I have found that these embedded systems don’t care much for nested conditions and don’t like events, in particular.

With VEXcode IQ Blocks, I coded a routine for a SumoBot to reverse and spin at a white line and spin slowly until it detects an opponent; and then charge. With embedded systems, a Loop forever, if..else if nesting is required:

If sense colour that is greater than 15 (white), then:
Stop driving
Reverse 5cm
Spin around 180 degrees
Else it is black, so
If ultrasonic sensor detects object (distance < 20) then:
drive forward at opponent
Else spin around slowly until detected


forever(function () {

if (sensors.color3.light(LightIntensityMode.Reflected) > 50) {


motors.largeBC.steer(0, –50, 2, MoveUnit.Rotations)

motors.largeBC.tank(-100, 100)

} else {

if (sensors.ultrasonic4.distance() < 20) {

motors.largeBC.steer(0, 100)

} else {

motors.largeBC.tank(-25, 25)

pauseUntil(() => sensors.ultrasonic4.distance() < 20)




VEXcode IQ Blocks

The issue that I had, when I tested out my code, was that there was a delay between detecting the opponent and charging forward; and so it would hit it at an angle or miss completely. I have found this in the past, with the way the code is compiled and run on the bot and issues with nested if statements. I figured the problem was the ‘wait until’, which should have been fine, or it would have been on an Arduino, anyway. Therefore, I modified the code to include a ‘while’ not statement.

This seems to have made the system much happier, as the results below show.