For more detailed information about the sketch process and the PRIZM library
functions involved in using the Ultrasonic Sensor and the serial monitor, refer to
www.arduino.cc and the appendix: TETRIX PRIZM Arduino Library Functions:
• Pages 134-135 about sensor port functions
Real-World Connection
When you were very, very young, you were probably scanned by an ultrasonic
sensor. If you do not remember this, it is because it was prior to you being born.
One of the great applications of ultrasonic technology is within the medical field.
Doctors can use the reflection of sound waves back to sensor waves to see inside
a living person. Doctors can see a baby’s size and development – and determine
when they think he or she might be born!
STEM Extensions
Science
• Sound wave terminology (frequency, amplitude, crest, trough)
• Reflection of sound waves
Technology
• Measuring frequency
• Sound digitization
Engineering
• Applications of sonic measurements
Math
• Inverse square law
Hacking the Code Activity
With the example as a reference, try creating a new sketch to use the Ultrasonic
Sensor with the serial monitor. Remember what we learned from our previous
activities and experiment with different objects in front of the Ultrasonic Sensor to
see if they are detectable and if the distances can be measured accurately.
Try changing the code for prizm.readSonicSensorCM() to prizm.readSonicSensorIN()
to display the distance from an object in inches. Also be sure to change the Serial.
printIn from “ Centimeters” to “ Inches” so that the unit is correctly labeled in the
serial monitor window. Understanding how to use the Ultrasonic Sensor will give
your robot vision to be able to steer around objects and obstacles.
Tip: In the sketch window
the PRIZM library functions
change color when they
are typed or spelled
correctly. Consequently,
if spelled incorrectly they
will not change. In Arduino,
the PRIZM functions are
recognized by the software
as keywords and will turn
orange when the syntax is
correct.
Tip: An example library of
code to help you get started
with this challenge can be
found in the appendix. If you
have a digital copy of this
guide, you can simply copy
and paste the sample code
for each activity into your
sketch window. A digital
download can be found at
www.TETRIXrobotics.com/
PRIZMdownloads.
32 Getting Started Activities