Micromelon Robotics
Platform
Resources
NewsAbout UsDownload
Support
Build Your Kit

Stay in the loop

New activities, teaching guides, and product updates delivered to your inbox.

Micromelon Robotics

Australian-made educational robotics for the next generation of innovators.

contact@micromelon.com.au

Company

  • About Us
  • Privacy Policy
  • Terms and Conditions

Products

  • Micromelon Rover
  • Code Editor
  • Robot Simulator
  • Junior
  • Python Library

Support

  • Resources
  • News
  • Rover Repairs
  • Contact
  • Build Your Kit

© 2026 Micromelon Robotics Pty Ltd. All rights reserved.

ABN 56 623 302 296

← Back to Resources
ActivitiesIntermediate

Activity: Puppy Bot

Coding Skills

BranchingIterationFunctions

Rover Concepts

UltrasonicMotors
Activity: Puppy Bot

Program the Rover to act like a puppy. When the Rover detects an object within 50 cm using the ultrasonic sensor, have it charge forward. Once it gets within 20 cm of the object, it stops and waits for the object to move. When Puppy Bot can’t see anything with the ultrasonic, it slowly spins on the spot, looking for something to follow.

Activity Demonstration: Puppy Bot

Setup

The distances used in the code can change depending on how much space you have. Keep in mind the max range of the ultrasonic sensor is about 100 cm, if it can’t detect anything, it returns a reading of 255 cm. The solution below can be extended with functions in each branch to make the Rover better at finding and following people.

Our Approach

Stage 1: Set Up the IF Branches

Start with an IF statement with 3 branches. First, if the Rover detects something within 20 cm with the ultrasonic sensor, stop. Then use an ELSE IF that checks if the Rover detects something within 50 cm. Lastly, the ELSE branch handles when the ultrasonic sensor doesn’t detect anything close.

Stage 2: Add Motor Blocks

Place appropriate motor blocks for each condition. When the Rover is stationary waiting for its owner to move, stop all motors. When the Rover starts to chase, move forward at high speed. When it senses nothing, slowly turn on the spot searching.

Stage 3: Loop Forever

Wrap everything in a While True loop so the behaviour repeats forever.

Example code, three-branch puppy behaviour

Example code, three-branch puppy behaviour

Continue Learning

Activity: Survey BotRelated resourceActivity: Survey BotLearn iteration while using the IR sensors.

Activity: Balance BotRelated resourceActivity: Balance BotLearn iteration, algorithm design, maths, and how to use the Rover’s accelerometer and motors.

The Ultrasonic SensorRelated resourceThe Ultrasonic SensorLearn what the ultrasonic sensor is, how it works, and how to code it on the Micromelon Rover.

← Return to Resources