Motomo Lab 2
Slides
Objective
With the prior coding knowledge, students will learn what a sonar sensor is and code for it. They will also teach the robot to interact with the world around it.
Activity
Students will learn what a sonar sensor is and what it measures.
Students will install it into the robot and have the robot make descisions on based on the information of the sensor.
Assessment
Students will learn to analyze problems
Students will teach the robot to make descisions based on the information of the sensor.
Students will learn a completely new sensor, the sonar sensor. This sensor allows the robot to measure distances between it and the object. This allows it to recognize objects close and far and avoid them.
Lab Summary:
Required Materials:
Photos | Item Name | Purpose | Required Quantity | Labeled Bag |
---|---|---|---|---|
Step 1
First Locate the servo. The servo is the brown cube on top of the front wheel. This servo is called MG90S. There are all types of servos ours can only turn from 0 to 180 degrees. Other servos can turn all around and some are built to lift heavy materials.
A servo is a DC motor that has been built to move accurately instead of infinetly turning. This allows us to code the servo to move to very specific directions fast and accurately. In our case, the library built for the servo is built to go from -90 degrees to 90 degrees. This means 0 degrees the wheel will point forward, -90 will point left, and 90 will point right. For any troubleshooting with angles and hardware refer to our troubleshooting page.
Step 1
Step 2
Set up the sonar sensor in the code, this includes defining the pins connected to the microcontroller. Try to print out the distance onto the terminal. There are two options, centimeters and milimeters. We can always conver to inches if you feel up to the challenge.
Step 3
Lastly, try to combine servo movement and DC motor movement. What the robot go left and right with the new hardware! Tips: For one motor, we will only have to the the motor to go forwards or backwards since the servo will be in charge of the turning.