To begin, press the green Start button. Your robot will travel forward until it senses
that it is within 25 cm of the object in its path.
When an object is detected, the robot will stop, back up, make a right turn, and
continue. Observe the behavior of the robot. Press the red Stop/Reset button to end
the sketch. Based on the sketch comments, did the behavior match expectations?
Further Investigate
This sketch uses the if-else block and uses multiple actions within the loop.
Each part of the if-else block here has multiple actions. In the if part of the block,
the Codee Bot is moving forward at 35% power with the green LED on while the
sensor watches for an object. In the else part of the block, when the Codee Bot
detects an object, the green LED turns off and the red LED turns on, and the Codee
Bot stops, backs up, and turns right. The loop then continues.
Extension Activity
With the example as a reference, try creating a new sketch to have the Codee Bot
avoid obstacles. Remember what you learned from your previous activities.
Challenge yourself and experiment with different objects or make an obstacle
course with multiple objects to detect. You can experiment and modify the
example code as needed to change the reaction and behavior of your robot’s
obstacle avoidance.
Real-World Link
Some new vehicles have sensors in the front that sense if an object is in front of
them. Imagine a deer running out in front of the car you’re riding in. The car would
automatically brake because it sensed the deer in front of it. The car avoided an
accident that would have occurred because of the collision with a deer.
Careers: test engineer, materials development engineer, measurement lab
technician
STEM Connections
• Science
Ĕ Sound waves
Ĕ Echolocation
• Technology
Ĕ Logic statements
Ĕ Motor applications
• Engineering
Ĕ Obstacle avoidance
Ĕ Steering
• Math
Ĕ Graphing
Ĕ Angles
Tip: When the robot
approaches an obstacle at
an angle, it might have a
challenge sensing the object.
Troubleshooting: Be sure
to check that the Ultrasonic
Sensor is plugged into the
correct sensor port and is
plugged in correctly. Keep
in mind that objects that are
small or have an irregular
surface might not be
detected or might affect the
distance the sensor reads.
Building and Coding the PULSE CodeeBot 117