You can use Blockly to create a program that continuously reads the distance measured by the ultrasonic sensor. If the distance is below a certain threshold, you can use blocks to light up specific LEDs on the matrix, indicating the presence of an obstacle. This can be achieved using if-else blocks and LED control blocks in Blockly.