Difference between revisions of "Itty Bitty Buggy: Example 3: Line Avoidance (mDesigner)"
(Created page with "=Introduction= Itty Bitty Buggy is capable of tracing lines, but what about avoiding them? This example will program Itty Bitty Buggy to avoid a line! =Overview= How can we m...") |
(→Overview) |
||
Line 15: | Line 15: | ||
Since Itty Bitty Buggy has two sets of Color Detectors, one on each side, labeled '''A''' (left side) and '''B''' (right side). (As labeled on the underside of Buggy Base.) | Since Itty Bitty Buggy has two sets of Color Detectors, one on each side, labeled '''A''' (left side) and '''B''' (right side). (As labeled on the underside of Buggy Base.) | ||
− | [[File: | + | [[File:IBB_Example3_Image1.png|800px]] |
We can detect which side we are approaching a line, based on which Color Detector senses the line. With this information, we can turn away from the line. | We can detect which side we are approaching a line, based on which Color Detector senses the line. With this information, we can turn away from the line. | ||
Line 21: | Line 21: | ||
If we detect the line on the '''A''' Color Detector (left side), we need to turn right in order to avoid it. | If we detect the line on the '''A''' Color Detector (left side), we need to turn right in order to avoid it. | ||
− | [[File: | + | [[File:IBB_Example3_Image2.png|800px]] |
To turn right, we can set the motors speeds to steer right. | To turn right, we can set the motors speeds to steer right. | ||
Line 29: | Line 29: | ||
If we detect the line on the '''B''' Color Detector (right side), we need to turn left in order to avoid it. | If we detect the line on the '''B''' Color Detector (right side), we need to turn left in order to avoid it. | ||
− | [[File: | + | [[File:IBB_Example3_Image3.png|800px]] |
To turn left, we can set the motors speeds to steer left. | To turn left, we can set the motors speeds to steer left. | ||
Line 37: | Line 37: | ||
If we do not detect a line on both the '''A''' and '''B''' Color Detectors, we are fine with going forward. | If we do not detect a line on both the '''A''' and '''B''' Color Detectors, we are fine with going forward. | ||
− | [[File: | + | [[File:IBB_Example3_Image4.png|800px]] |
To go forward, we can set the motors speeds to move forward. We have the the motors at a slow speed going forward as it gives Itty Bitty Buggy a chance to detect the line. Moving forwarded too fast can cause Itty Bitty Buggy to simply skip over the line without avoiding it. | To go forward, we can set the motors speeds to move forward. We have the the motors at a slow speed going forward as it gives Itty Bitty Buggy a chance to detect the line. Moving forwarded too fast can cause Itty Bitty Buggy to simply skip over the line without avoiding it. | ||
[[File:img.png]] | [[File:img.png]] |
Revision as of 23:52, 2 November 2018
Introduction
Itty Bitty Buggy is capable of tracing lines, but what about avoiding them? This example will program Itty Bitty Buggy to avoid a line!
Overview
How can we make it so Itty Bitty Bug avoids a line instead of tracing it?
First, how can we detect a line? We can use the Color Detector to do so. But which block?
The Color Detector - Detect Color block of course! It is capable of detecting colors, which means it can be used to detect a colored line.
Great, so, we are able to detect a line, what next? We need to avoid it. How can we avoid it? We can turn away from the line. But which way?
Since Itty Bitty Buggy has two sets of Color Detectors, one on each side, labeled A (left side) and B (right side). (As labeled on the underside of Buggy Base.)
We can detect which side we are approaching a line, based on which Color Detector senses the line. With this information, we can turn away from the line.
If we detect the line on the A Color Detector (left side), we need to turn right in order to avoid it.
To turn right, we can set the motors speeds to steer right.
If we detect the line on the B Color Detector (right side), we need to turn left in order to avoid it.
To turn left, we can set the motors speeds to steer left.
If we do not detect a line on both the A and B Color Detectors, we are fine with going forward.
To go forward, we can set the motors speeds to move forward. We have the the motors at a slow speed going forward as it gives Itty Bitty Buggy a chance to detect the line. Moving forwarded too fast can cause Itty Bitty Buggy to simply skip over the line without avoiding it.