Matthew Xu's Coding Projects

My name is Matthew, and I am 12 years old. I began learning robotics with LEGO Mindstorms and block-based coding when I was in Primary 4. I enjoy designing and building different structures and robots, especially those that help automate simple daily tasks. Learning robotics taught me how to solve real-world problems and sparked my curiosity to explore beyond block-based coding. That was when I became interested in Python, a text-based programming language. I wanted to create programs that could help me solve math problems without using pen and paper. I also learned how to use Pygame, where I developed various games for my friends to play and challenge one another. Throughout this journey, I have been documenting my experiences in robotics, coding, innovation, and STEM.

Portrait of Matthew Xu

Project 1: Bumper Car

Bumper Car

I learned how to use LEGO Technic parts to design and build functional mechanical systems. By applying coding concepts such as conditionals (if-else) and integrating various sensors, I programmed my creations to respond dynamically to their environment. One example was a bumper car that automatically reverses when its front touch sensor detects a collision— mimicking real-world applications of obstacle detection in autonomous vehicles and robotic systems.

Project 1: Bumper Car
Project 2: Ultrasonic Activated Tractor
Project 2: Ultrasonic Activated Tractor

Ultrasonic Activated Tractor

I used LEGO Technic parts to build a tractor with an ultrasonic sensor. When the tractor detects a load placed on it, it automatically starts moving. This is similar to autonomous track-based vehicles used to transport goods in warehouses. Once the sensor detects an object, the vehicle moves to deliver the item to a designated location, helping increase efficiency and reduce the need for manual labor.

Project 3: Distance Sensor Coin Dispenser

Distance Sensor Coin Dispenser

Inspired by arcade coin dispensers, I applied the design principles and coding skills I learned to build a distance-activated coin dispenser. The dispenser uses two ultrasonic sensors that detect my hand in a specific sequence within a defined distance threshold. When both sensors are triggered in order, the mechanism opens to release coins. This project demonstrates how sensor integration and conditional logic can create automated systems, similar to those used in vending machines .

Project 3: Distance Sensor Coin Dispenser
Project 4: Ultrasonic Activated Automated Car
Project 4: Ultrasonic Activated Automated Car

Ultrasonic Activated Automated Car

I decided to create an automated car using LEGO Technic parts that can return to its original parking position after detecting an obstacle. This project simulates the logic behind autonomous parking systems found in modern vehicles. Using the concept of nested while loops with variables, I programmed the car to activate and begin moving when the touch sensor is activated. While in motion, the car continuously checks for obstacles using the ultrasonic sensor. Once an obstacle is detected, the car automatically stops and reverses back to its starting point—mimicking a vehicle returning to its parking spot.

Project 5: Colour & Ultrasonic Activated Spinning Top

Colour & Ultrasonic Activated Spinning Top

Playing the top is my childhood game and I decided to recreate a sensor-controlled spinning top using LEGO technic parts and coded it to move when it is activated by a colour sensor. I could control the direction it spins using an ultrasonic sensor when it detects someone within different range. If the ultrasonic sensor detects someone near it, it will spin clockwise, else, it spins anti-clockwise. This setup mirrors real-life smart devices that respond to environmental cues. The system responds intuitively to human presence, creating an interactive and dynamic user experience.

Project 5: Colour & Ultrasonic Activated Spinning Top