# Automatic Sorter

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## Overview

Design a timed 设计一个定时喂食器，当你不在家时，可以定时给宠物投喂食物。

## Module Bill

### Modules

 Module Number Function mCookie-Core 1 Core board Battery 1 Program download and power supply mCookie-Hub 1 Sensor adapter plate Line Finder 2 Detect objects Servo 1 Servo Servo connector 1 Servo connector

### Other Equipment

• USB cable*1
• Sensor cable*2
• Sensor shell
• Lego or other fixation structures

## Module Setup

### Assembly

• Assemble modules and sensors together:
• Connect the servo connector to pin 6/7 of Hub;
• Connect the servo to pin 1 (the below three pins) of servo connector;
• Connect the Line Finder to pin A0/A1 of Hub;
• Plug one end of the USB cable into the battery and connect the other end to computer;

## Programming

### Programming Thought

After finding objects, the Line Finder will delay 1s for the object being put down, if the gray level of it meets the block judgment standard, slide the block into the right circle, and the manipulator arm gets back to the horizontal state.

### Start to Program

1.
Judge there is an object If the distance value of the Line Finder is less than 700 (representing there is something ahead), delay 1s for the object to be put stably.
2. If the reflectance of the object meets the block standard, slide the block into the right circle.
If the gray level of Line Finder is less than 250 (the reflectance level meets the block standard), rotate the servo to 60 degrees (slide the block into the right circle). Rotate the servo to 90 degrees (the manipulator arm gets back to horizontal).

Test the result
After uploading the program, take a non-black Lego block approaching to the Line Finder, and the servo will rotate from 90 degrees to 60 degrees, and then rotate to 90 degrees again.
Fix the leaning board and the servo together, and install the line finder into the slot facing the leaning board to detect the gray level.

Q: If the sorter now identify junk (black), it will stop and keep still, how to make it throw the junk?
A:Make the servo rotate to another direction and throw the junk to other side.

If the gray level of the object doesn’t meet the standard, throw it away.