Lego sort and sort
In this blog, I will illustrate the overall design that I followed for the Lego Sorter, hopefully saving you tens of hours if you pursue a similar endeavor.
It was clear from the start, that having an automated way of capturing hundreds or even thousands of images would be a central capability to successfully implement a Neural Network.
I had no prior experience with the “Internet of Things”, but after taking some advice and doing some research, I decided to base the automated sorter on a Raspberry Pi augmented with boards to handle Motors and Sensors.
My objective was to build the “shortest path” that would enable me to hit the software stage, where I would focus on the Artificial Intelligence.
Tip: During the course of this project, I realized that the Raspberry Pi is very flexible but does have some limitations as a micro-controller, even when using Hats (things like bus speeds become a limitation, etc.). In retrospective, I would have used Arduino, specifically to control the motors.
First Iteration
This was my first design, and it had some important limitations:
- The feeder would drop multiple blocks aligned in parallel to the conveyor drop, which defeated any separation attempt.
- The conveyor was too narrow, which made some pieces fall off and prevent the addition of guiding walls to regulate speed.
Final Design
I don’t believe achieving this would have been possible without having access to a reliable 3D Printer. I used a Prusa Mk2 printer and it enable me to very quickly design and build all the parts that I needed on demand.
I did some research across documented approaches to sorting a bulk set of Legos, and found two great references:
I was already inspired by akijuki’s design, planning on building two conveyor belts, so I decided to avoid having to build a third conveyor, so I took the approach from akiyuki: using a mechanical pusher and incline to feed the Legos.
The feeder can roughly hold 100–150 pieces on average, and it’s operated by a continuously rotating servo, using an elliptical servo adapter to drive the pusher up and down.
The conveyor belt system is the centerpiece of the separation activities, and again, I did use a lot of inspiration from akiyuki’s Lego Mindstorm Sorter.
The fundamental design relies on speed differentials enable the Lego blocks to separate individual (in preparation for image capture).
There is a half and inch drop between conveyors, which are moving at different speeds. I quickly found that this was not enough to reliable separate the pieces, and had to do some more research.
I found some great industrial application of conveyor based sorting and separation and decided to implement guiding was to further drive speed differential along the route to the image capture. You can see here where I took the inspiration:
I mulled over a two options to identify when the block was in place. I could continuously capture Video and through Image recognition detect the piece, or I could place a IR Beam Sensor to physically identify when the block was in range of the camera.
At this stage, I still hadn’t dwelved into OpenCV, so I decided for the IR Beam Sensor option and placed three IR Beam sensors across the machine: one at the location of the image capture, and one at the end of each conveyor.
From a software perspective, I only used one of the sensors: the signal of the image capture sensors.
Part of the Image Capture modules rely on OpenCV and image recognition. I found that when White blocks would come into range, I couldn’t reliably detect their contours or edges.
Placing a LED Backlight provided much better contrast to the image capture and increased the detection accuracy very close to 100%.
I initially chose a three way separator using two servo motors which proved to not be a good approach. It was a bit complex to setup and it proved to be extremely limiting in terms of the ability to test a neural network across many classes.
I did some research and found that the easiest way to achieve multi-bin sorting was through rotation, which also simplified the design by relying on a single servo.
My current build has 12 bins and could probably support up to 14 or 15 in total.
From a software perspective, I use 1 bin to sort pieces that did not achieve mechanical separation, which reduces the effective sorting capacity down to 11 bins.
This part of a 5 Blog Series to cover the mechanical and software design for the Lego Sorter, as well as sharing the training set and some evaluation sets:
The right Lego Sorter will get you done 10x faster. It will make the whole process fun and easy. But sorting by hand is a nightmare. It is slow, boring and never seems to end. Plus, you get to do it again every time you build or pick up new bricks. That's why choosing the right way to sort your Lego bricks is such an important decision.
Why Do You Want A Lego Sorter?
You came here looking for a Lego Sorter. Maybe you started sorting your bricks by hand and realized how long it was going to take. (It takes so, so long) Or you are sick of digging through the unsorted bin of bricks and want to give it some order. If you are a Lego parent you might be looking for a way to help your kids build more with their current collection. In any case I can help you.
I have been where you are. I have tried to sort my collection by hand. I have used all the different tools I could find to help. I have gotten frustrated and put it aside. I have a 7 yr old boy who plays with our bricks every day. So I know about the mess, cleaning, re-cleaning and stepping on bricks.
I have also found a solution that works. A way to quickly organize your bricks so that you can find any part in just seconds. (My son understood it all the first day) I created a special sorting tool that speeds the process up 10x. (and it's easy to build) In fact I have put together an entire system for Sorting, Organizing and Storing Lego called Sorted By Sunday.
But today you came to learn about Lego sorters and before I can explain all of your options and tell you how they work, I want to make a few things clear. There is a difference between Lego Sorting, Lego Organizing, and Lego Storage. Each piece is very important and needs to be planned.
Lego Sorting Tip
For most builders, sorting your Lego bricks is the slowest and most annoying part of organizing your collection. You can do it all by hand, but it will take a very, very long time. This is usually the reason people don't finish working on their collection. If you want a much faster way check out our Free Lego Sorting Guide.
Sorting, Organizing and Storing Lego
Sorting is the process of taking a bin full of mixed up pieces and putting them into groups. It can be done by hand, with a simple tool like a sifter, or using a complex machine. In any of these cases all that the Lego Sorter does is to speed up the process of putting bricks in groups.
Organizing is the way you group your bricks together. Do you match them by color, or by function? What pieces go together and why. Do you mostly build custom creations, rebuild old sets, or build on your Lego wall? Understanding this will help you decide how to organize your Lego collection and if you really need a big Lego Organizer.
Storage is simply what you put the bricks in. Bins, boxes, bags and totes. There are more different ways to store your bricks than you can imagine. In fact Lego Storage is such a huge subject that I have a whole section of the website just for it. Make sure you understand this before you start sorting your bricks or you will probably buy a bunch of stuff you don't really need.
Out Of Production
Unfortunately most of the Lego size sorters below are no longer being produced or sold. By themselves the just weren't that useful, but combined with the right tools they can be amazing. Learn more in our Free Sorting Guide.
3 Kinds Of Lego Sorter
When I went searching for a faster way to sort my bricks I found 2 different types out there. The simple sifter/shaker sorting tools and the complex artificial intelligence sorting machines some people had built. Both have some serious problems. so I built a 3rd type.
Lego Shake/Sift Sorters
Lego shake sorters come in a few different styles. The most common is the Lego Sort and Store Head. These used to retail for around $40, but were discontinued a few years ago. They are still around on Ebay for about the same price.
The square one above is made by Box4Blocks a company from New Zeland. Their website says they are working on a new design, but it hasn't been updated in years so I don't think they are still moving forward. Lastly the round one on the left was made by Blokpod and sold on Amazon. This is actually the one I bought although they are no longer selling them. (notice a pattern)
The main reason these never caught on is that they don't work very well. The design is simple, a series of screens with smaller holes as you move toward the bottom. You are supposed to load your mixed bricks into the top and give it a shake. All your little pieces are sorted into 4 different sizes.
First of all, if your collection is more than a few thousand bricks (and most are) you need more than 4 different groups. Yes I believe sorting by size is important. We all know how difficult it is to find those little 1x2 plates that find there way to the bottom. But there are over 3,700 different Lego elements and 182 colors. Four groups would put 1000s of different parts in each bin, you will still have trouble finding your bricks.
Second, they don't work as advertised. Yes they are fast, but lots of long skinny bricks (like Technic Axles) get stuck at the top because they are not facing the right way to fall. Sure shaking helps, but in my experience you get about 50% of the bricks that fit, to fall through the screen. The rest have to be helped along.
Technic liftarms get stuck at all levels depending on their length.
They are small enough to fit through the bottom holes.
To be completely clear I like the Blokpod. It is well made and the sizes of hole were chosen to match Lego bricks. I think it is a fast and useful tool, but it isn't enough alone, I will explain soon.
If you want one of these you can find them in the used market. Otherwise there are lots of tutorials for DIY Lego Sorters. Some are made by drilling holes in boards or buckets. There is even someone who made one with tennis racket string. This is a pretty simple and easy to build tool if you need one.
AI Driven Automated Lego Sorters
These are absolutely amazing. They are feats of computer and mechanical engineering that blows my mind. They sort Lego bricks faster and more precisely than anything out there. These are by far the fastest way to sort bricks, but you have to make it on your own.
They use belts, blowers and shakers to separate each brick. Then a camera takes a picture of it and the computer recognizes which brick it is. After that it is shuttled off to the correct location.
There are many different versions. Some are faster and more precise. Each builder seems to improve on the last design and someday there might be one for sale. Until then you will not be sorting your bricks this way.
Plus, they are also like shooting a mosquito with a bazooka. If you are a Lego Master Builder and sort millions of bricks a month, you need this. For everyone else, it will take longer to make than it would to hand sort.
The Speed Sorter
I realized pretty early on that nothing on the market was really going to help me sort my bricks. So I spent some hours on YouTube looking at Lego sorting videos.
Some people were showing their sorting techniques, but most were just showing off their massive, perfectly organized, Lego rooms. It was at this point that I realized a few things.
Design, build, and program a machine that can identify at least three different colors of LEGO ® elements and sort them into separate locations.
Lesson plan
Prepare
- Read through this teacher material.
- If you feel it is needed, plan a lesson using the getting started material in the EV3 Lab Software or EV3 Programming app. This will help familiarize your students with LEGO ® MINDSTORMS ® Education EV3.
Engage (30 Min.)
- Use the ideas in the Ignite a Discussion section below to engage your students in a discussion related to this project.
- Explain the project.
- Split your class into teams of two students.
- Allow your students some time to brainstorm.
Explore (30 Min.)
- Have your students create multiple prototypes.
- Encourage them to explore both building and programming.
- Have each pair of students build and test two solutions.
- Provide students with cups or other containers to hold the sorted objects.
Explain (60 Min.)
- Ask your students to test their solutions and to choose the best one.
- Make sure they can create their own testing tables.
- Allow some time for each team to finalize their project and to collect assets for documenting their work.
Elaborate (60 Min.)
- Give your students some time to produce their final reports.
- Facilitate a sharing session in which each team presents their results.
Evaluate
- Give feedback on each student’s performance.
- You can use the assessment rubrics provided to simplify the process.
Ignite a Discussion
Sorting machines can sort objects based on properties, such as size, weight, quality, or color. They use a variety of sensors to measure these properties and then sort each object into the correct category.
PLAY
Encourage an active brainstorming process.
Ask your students to think about these questions:
- Which colors will you sort?
- What size elements will you sort?
- Which type of motorized mechanism can move those elements?
- How can the machine sense different locations?
- What design features will ensure the machine’s movements are accurate and repeatable?
Encourage students to document their initial ideas and explain why they picked the solution they will use for their first prototype. Ask them to describe how they will evaluate their ideas throughout the project. That way, when they are reviewing and revising, they will have specific information they can use to evaluate their solution and decide whether or not it was effective.
Language Arts Extension
To incorporate language arts skills development, have your students:
- Use their written work, sketches, and/or photos to summarize their design process and create a final report.
- Create a video demonstrating their design process starting with their initial ideas and ending with their completed project.
- Create a presentation about their program.
- Create a presentation that connects their project with real-world applications of similar systems and describes new inventions that could be made based on what they have created.
Building Tips
Building Ideas
Give your students an opportunity to build some examples from the links below. Encourage them to explore how these systems work and to brainstorm how these systems could inspire a solution to the Design Brief.
Testing Tips
Encourage your students to design their own test setup and procedure to select the best solution. These tips can help your students as they set up their test:
- Mark the location to show where the machine should place objects.
- Use cups or other containers to hold the sorted objects.
- Create testing tables to record your observations.
- Evaluate the precision of your machine by comparing the expected results with the actual results.
- Repeat the test at least three times.
Sample Solution
Here is a sample solution that meets the Design Brief criteria:
PLAY
Coding Tips
EV3 MicroPython Sample Program
Career Links
Students who enjoyed this lesson might be interested in exploring these careers pathways:
- Agriculture and Horticulture (Agricultural Mechanics and Technology)
- Manufacturing and Engineering (Machine Technology)
Assessment Opportunities
Teacher Observation Checklist
Create a scale that matches your needs, for example:
- Partially accomplished
- Fully accomplished
- Overachieved
Use the following success criteria to evaluate your students’ progress:
- Students can evaluate competing design solutions based on prioritized criteria and tradeoff considerations.
- Students are autonomous in developing a working and creative solution.
- Students can clearly communicate their ideas.
Self Assessment
Once your students have collected some performance data, give them time to reflect on their solutions. Help them by asking questions, like:
- Is your solution meeting the Design Brief criteria?
- Can your machine’s movement(s) be made more accurate?
- What are some ways that others have solved this problem?
Ask your students to brainstorm and document two ways they could improve their solutions.
Peer Feedback
Encourage a peer review process in which each group is responsible for evaluating their own and others’ projects. This review process can help students develop skills in giving constructive feedback as well as sharpen their analysis skills and ability to use objective data to support an argument.
Design, build, and program a machine that can identify at least three different colors of LEGO ® elements and sort them into separate locations.
Lesson plan
Prepare
- Read through this teacher material.
- If you feel it is needed, plan a lesson using the getting started material in the EV3 Lab Software or EV3 Programming App. This will help familiarize your students with LEGO ® MINDSTORMS ® Education EV3.
Engage (30 Min.)
- Use the ideas in the Ignite a Discussion section below to engage your students in a discussion related to this project.
- Explain the project.
- Split your class into teams of two students.
- Allow your students some time to brainstorm.
Explore (30 Min.)
- Have your students create multiple prototypes.
- Encourage them to explore both building and programming.
- Have each pair of students build and test two solutions.
- Provide students with cups or other containers to hold the sorted objects.
Explain (60 Min.)
- Ask your students to test their solutions and to choose the best one.
- Make sure they can create their own testing tables.
- Allow some time for each team to finalize their project and to collect assets for documenting their work.
Elaborate (60 Min.)
- Give your students some time to produce their final reports.
- Facilitate a sharing session in which each team presents their results.
Evaluate
- Give feedback on each student’s performance.
- You can use the assessment rubrics provided to simplify the process.
Ignite a Discussion
Sorting machines can sort objects based on properties, such as size, weight, quality, or color. They use a variety of sensors to measure these properties and then sort each object into the correct category.
PLAY
Encourage an active brainstorming process.
Ask your students to think about these questions:
- What is a sorting machine and where are they used?
- Which colors will you sort?
- What size elements will you sort?
- Which type of motorized mechanism can move those elements?
- How can the machine sense different locations?
- What design features will ensure the machine’s movements are accurate and repeatable?
Encourage students to document their initial ideas and explain why they picked the solution they will use for their first prototype. Ask them to describe how they will evaluate their ideas throughout the project. That way, when they are reviewing and revising, they will have specific information they can use to evaluate their solution and decide whether or not it was effective.
Extensions
Language Arts Extension
Option 1
To incorporate language arts skills development, have your students:
- Use their written work, sketches, and/or photos to summarize their design process and create a final report
- Create a video demonstrating their design process starting with their initial ideas and ending with their completed project
- Create a presentation about their program
- Create a presentation that connects their project with real-world applications of similar systems and describes new inventions that could be made based on what they have created
Option 2
In this lesson, your students created a sorting machine. The food and farming industries use sorting machines to manage product production and distribution on large scales.
To incorporate language arts skills development, have your students:
- Describe the scale of their local and regional food or farm industries
- Pick a specific food or farm product at a specific scale ranging from small business/farm to national or global level production, and research cybersecurity issues relating to the food and farming industries (e.g., how to ensure safe, reliable food production)
Math Extension
In this lesson, your students built a robotic sorting machine that sorted objects based on color. Machine learning is a technique engineers can use to build machines that sort objects according to differences that are even more complex than color. To achieve this, developers use a machine learning process called classification.
To incorporate math skills development, and explore the machine learning process called classification, have your students:
- Collect some type of sortable objects (e.g., rocks, types of fruit, bracelets) and then populate a data table listing observable qualitative and quantitative differences between the objects
- Define what observable differences would lead to "desired" vs. "not desired" (e.g., weight, color, size, imperfections) sorting criteria for any single category of objects
- Propose and possibly build a new sorting design and programming algorithm for their robots that would enable them to sort for additional characteristics such as size or weight
Building Tips
Building Ideas
Give your students an opportunity to build some examples from the links below. Encourage them to explore how these systems work and to brainstorm how these systems could inspire a solution to the Design Brief.
Testing Tips
Encourage your students to design their own tests setup and procedure to select the best solution. These tips can help your students as they set up their test:
- Mark the location to show where the machine should place objects.
- Use cups or other containers to hold the sorted objects.
- Create testing tables to record your observations.
- Evaluate the precision of your machine by comparing the expected results with the actual results.
- Repeat the test at least three times.
Sample Solution
Here is a sample solution that meets the Design Brief criteria:
PLAY
Coding Tips
EV3 MicroPython Sample Program
Career Links
Students who enjoyed this lesson might be interested in exploring these career pathways:
- Agriculture and Horticulture (Agricultural Mechanics and Technology)
- Manufacturing and Engineering (Machine Technology)
Assessment Opportunities
Teacher Observation Checklist
Create a scale that matches your needs, for example:
- Partially accomplished
- Fully accomplished
- Overachieved
Use the following success criteria to evaluate your students’ progress:
- Students can evaluate competing design solutions based on prioritized criteria and tradeoff considerations.
- Students are autonomous in developing a working and creative solution.
- Students can clearly communicate their ideas.
Self-Assessment
Once your students have collected some performance data, give them time to reflect on their solutions. Help them by asking questions, like:
- Is your solution meeting the Design Brief criteria?
- Can your machine’s movement(s) be made more accurate?
- What are some ways that others have solved this problem?
Ask your students to brainstorm and document two ways they could improve their solutions.
Peer Feedback
Encourage a peer review process in which each group is responsible for evaluating their own and others’ projects. This review process can help students develop skills in giving constructive feedback as well as sharpen their analysis skills and ability to use objective data to support an argument.
Teacher Support
Students will:
-Use the design process to solve a real-world problem
Cups or other containers to hold the sorted objects
Tape to mark locations
Main Standards
NGSS
HS-ETS1-2 Design a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.
HS-ETS1-3. Evaluate a solution to a complex real-world problem-based on prioritized criteria and trade-offs that account for a range of constraints, including cost, safety, reliability, and aesthetics, as well as possible social, cultural, and environmental impacts.
CSTA
3A-AP-13 Create prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.
3A-AP-17 Decompose problems into smaller components through systematic analysis, using constructs such as procedures, modules, and/or objects.
3A-AP-18 Create artifacts by using procedures within a program, combinations of data and procedures, or independent but interrelated programs.
ISTE Nets
4. Innovative Designer
a. know and use a deliberate design process for generating ideas, testing theories, creating innovative artifacts or solving authentic problems.
b. select and use digital tools to plan and manage a design process that considers design constraints and calculated risks.
c. develop, test and refine prototypes as part of a cyclical design process.
d. exhibit a tolerance for ambiguity, perseverance and the capacity to work with open-ended problems.
5. Computational Thinker
c. break problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
d. understand how automation works and use algorithmic thinking to develop a sequence of steps to create and test automated solutions.
6. Creative Communicator
a. choose the appropriate platforms and tools for meeting the desired objectives of their creation or communication.
Extensions Standards
Math Extension
CCSS.MATH.PRACTICE.MP2 Reason abstractly and quantitatively.
CCSS.MATH.PRACTICE.MP3 Construct viable arguments and critique the reasoning of others.
CCSS.MATH.PRACTICE.MP4 Model with mathematics.
Language Arts Extension
CCSS.ELA-LITERACY.W.9-10.1 Write arguments to support claims.
CCSS.ELA-LITERACY.W.9-10.2 Write informative/explanatory texts to examine and convey complex ideas, concepts, and information.
Design, build and program a robotic system that can identify at least three different colors of LEGO elements and sort them into separate locations.
Connect
( 30 minutes )
PLAY
Use this video to:
- Connect students to real-life robotic systems
- Consider how robotic systems are made up of smaller subsystems
- Inspire students to create their own robotic systems
Make a System Discussion
- Robotic systems are built from smaller, related subsystems. Look at the automobile system shown in the video. What subsystems can you see?
Answers can vary but may include describing the automobile manufacturing system with one subsystem for moving the car into position and multiple robotic subsystems welding components on different parts of the car.
2. What other systems and subsystems do you see in the video?
Answers may vary but may include describing the box-sorting conveyor system that separates boxes of different sizes. This system has two conveyor lines: one for larger boxes and one for smaller boxes. There is also a more complex sorting system that manages a larger volume of boxes and many more possible locations using multiple sorting arms and conveyors.
Design Brief
Design, build and program a robotic system that can identify at least three different colors of LEGO elements and sort them into separate locations.
Brainstorm
Encourage an active brainstorming process so that students develop their conceptual understanding. For example, encourage them to:
- Review the Robots In Action videos showing robots for inspiration
- Investigate Key Concepts Systems and Subsystems
- Build some of the examples from Building Ideas and explore how they work
- Personalize their robot or describe a context in which a robot sort other objects (e.g., conveyor sorting system in the Logistics video).
Select the Best Solution
Describe the solution that you have agreed to build and program.
Think about examples from your brainstorming discussion. Then explain why you chose this solution for the design brief. Encourage students to describe why they have chosen this solution. That way, when students are reviewing and revising, they will have specific information to use to evaluate their solution and decide whether or not it was effective.
Construct
( 30 minutes )
Build and Program
Start building and programming your solution!
As you work on your solution, make sure students keep track of:
- Describe one part of your design that worked especially well.
- Describe one design change that you had to make.
- What will you try next?
Students can use images, video, text, sound, or weblinks to document their work.
Test Set Up and Procedure
Materials needed: Three cups or other containers to hold the sorted objects, tape to mark locations.
- Position your robot. Mark the starting position.
- Next, mark the location to show where the robot should place objects.
- Mark the locations for the second and third colors and place a cup over each.
- Run your program.
- Repeat at least three times.
Instead of using cups, students can use paper and mark three locations, one for each color; however, it may be harder to control the Color Squares if they are dropped by the robot.
Depending on the students’ skill level, they can use Cartesian coordinates to indicate the expected and actual coordinates.
Contemplate
( 30 minutes )
Test and Analyze
How well does your solution satisfy the design brief?
Use a table to record data. Name the columns and rows, such as Trial Number, Expected position, Actual position, Difference and **Changes? **
Review and Revise
Take a moment to reflect on your robot solution.
- Can the robot movement be made more accurate?
- What are some ways that others have solved the problem?
Encourage students to look back at the design brief and at their own brainstorming notes and test data. Encourage a peer-review process so that each group is responsible for evaluating their own and others’ projects. This review process can help students develop skills in giving constructive feedback as well as sharpening analysis skills and the use of objective data to support an argument.
You may wish to provide students with the specific precision level to aim for (e.g., within 0.5 cm).
Communicate
Here are some ideas to suggest to students:
- Create a video of your project, especially your final presentation and your robot’s performance.
- Explain some important features of your software program.
- Produce a building guide for your model by taking a series of photographs as you deconstruct it.
- Include an image of your program with comments.
- Add a team photograph
Evaluate Design and NGSS Goals
You can use the included rubrics to evaluate skills progression of Design Engineering Projects.
- Students can review their design goals as well as their use of some NGSS practices using the provided rubric. Students can rate their level of work by adding a mark below the Bronze, Silver, Gold, or Platinum column.
- You may also choose to use the rubric to rate each team or student yourself.
Evaluate Creativity and Collaboration
Students can review their creative and collaboration processes using the provided rubric.
You may also choose to use the rubric to rate each team or student yourself.
Continue
( 30 minutes )
Communicate
Here are some ideas to suggest to students:
- Create a video of your project, especially your final presentation and your robot’s performance.
- Explain some important features of your software program.
- Produce a building guide for your model by taking a series of photographs as you deconstruct it.
- Include an image of your program with comments.
- Add a team photograph
Evaluate Design and NGSS Goals
You can use the included rubrics to evaluate skills progression of Design Engineering Projects.
- Students can review their design goals as well as their use of some NGSS practices using the provided rubric. Students can rate their level of work by adding a mark below the Bronze, Silver, Gold, or Platinum column.
- You may also choose to use the rubric to rate each team or student yourself.
Evaluate Creativity and Collaboration
Students can review their creative and collaboration processes using the provided rubric.
You may also choose to use the rubric to rate each team or student yourself.
Sample Solution Overview
The Sorter Bot Solution is one example of many possible solutions for the Make a System That Sorts Colors project.
PLAY
Sample Solution Building Ideas
The Sorter Bot combines these Building Ideas: Large Motor and Wheels, Chute, Color Squares.
Sorter Bot also added the Color Sensor and Ultrasonic Sensor.
Sample Solution Program
- Displays Hourglass 0
- Waits for you to load the Color Squares in the Chute and press a button
- Resets the Display
- Measures the color using the Color Sensor
If Blue, the program:
- Plays the Blue sound
- Turns on Motors B and C in opposite direction at 50% power
- Waits until the Ultrasonic Sensor sees the Blue location at 35cm distance from the wall
- Turns off Motors B and C
- Turns on Motor A and 360° (one rotation) to push out the blue Color Square
- Turns on Motors B and C to move back toward the wall
- Waits until the Ultrasonic Sensor sees the wall at 10 cm or less
- Turns off Motors B and C
If Yellow, the program:
- Plays the Yellow sound
- Turns on Motors B and C in opposite direction at 20% power
- Waits until the Ultrasonic Sensor sees the Yellow location at 20cm distance from the wall
- Turns off Motors B and C
- Turns on Motor A and 360° (one rotation) to push out the yellow Color Square
- Turns on Motors B and C to move back toward the wall
- Waits until the Ultrasonic Sensor sees the wall at 10 cm or less
- Turns off Motors B and C
If Red, the program:
- Plays the Red sound
- Turns on Motors B and C in opposite direction at 20% power
- Waits until the Ultrasonic Sensor sees the Blue location at 50cm distance from the wall
- Turns off Motors B and C
- Turns on Motor A and 360° (one rotation) to push out the red Color Square
- Turns on Motors B and C to move back toward the wall
- Waits until the Ultrasonic Sensor sees the wall at 10 cm or less
- Turns off Motors B and C
If Green, the program:
- Plays the Sorry sound
- Waits for 3 seconds
- Turns on Motor A and 360° (one rotation) to push out the green Color Square
If No Color is seen, the program:
- Displays Image Stop 1
- Waits for 2 seconds
- Resets the Display
- Interrupts Loop 01 so that you can load more Color Squares into the Chute
Unless interrupted by an empty Chute, the color-checking Loop 01 runs 5 times. Five Color Squares fit into the Chute.
Читайте также: