Conveyor Sorting System – Guided Documentation

Objective

Design and build a system that:

1. System Overview

Think about the system in three parts:

Motion System

A stepper motor continuously moves the conveyor

Sensing System

A color sensor reads RGB values

Action System

Servos push objects into the correct bin

Your task is to connect these parts logically.

2. Stepper Motor (Provided – Study Carefully)

Pin Definitions

#define STEP_PIN 3
#define DIR_PIN 4
#define ENABLE_PIN 6

STEP_PIN sends pulses to move the motor.
DIR_PIN controls direction.
ENABLE_PIN turns the driver on or off.

Question: Why might the motor driver require an enable pin?

Basic Step Function

void stepMotor() {
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(stepDelay);
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(stepDelay);
}

One HIGH to LOW pulse equals one step.
The delay controls how fast steps happen.

Key Idea:

Question: What happens if the delay is too small?

Moving a Specific Distance

void moveToBox(float revolutions) {
  long stepsToTake = revolutions * stepsPerRev;

  for (long i = 0; i < stepsToTake; i++) {
    stepMotor();
  }
}

The motor moves in steps, not distance units.
We convert revolutions into steps.

Key Idea:

Question: Why use revolutions instead of raw steps?

Stepper Setup

pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
pinMode(ENABLE_PIN, OUTPUT);

digitalWrite(ENABLE_PIN, LOW);
digitalWrite(DIR_PIN, HIGH);

Pins must be outputs.
ENABLE is often active LOW.
Direction controls movement orientation.

Try: Change direction and observe behavior.

How the Stepper Is Used

The motor moves continuously using stepMotor().
When a color is detected, moveToBox() moves to a sorting position.

Question: What happens while moveToBox() is running?

3. Color Detection Logic (You Design This)

The sensor provides:

Your task is to classify colors using comparisons.

Hints:

Questions:

4. Servo Control (You Implement This)

Each servo should:

Hints:

Questions:

5. Main Loop Logic (You Build This)

Your loop should:

  1. Move the conveyor slightly
  2. Check for color detection
  3. If detected:
    • Identify color
    • Move to position
    • Activate servo

Key Idea: The conveyor runs continuously until action is needed.

Question: Should the conveyor stop during sorting?

6. Integration Thinking

Consider:

7. Testing and Adjustment

8. Extension Challenge

Add another color:

Final Thought

This system combines continuous motion, sensing, and mechanical action. Focus on how these parts interact, not just how they work individually.