Design and build a system that:
Think about the system in three parts:
A stepper motor continuously moves the conveyor
A color sensor reads RGB values
Servos push objects into the correct bin
Your task is to connect these parts logically.
#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?
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?
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?
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.
The motor moves continuously using stepMotor().
When a color is detected, moveToBox() moves to a sorting position.
Question: What happens while moveToBox() is running?
The sensor provides:
Your task is to classify colors using comparisons.
Hints:
Questions:
Each servo should:
Hints:
Questions:
Your loop should:
Key Idea: The conveyor runs continuously until action is needed.
Question: Should the conveyor stop during sorting?
Consider:
Add another color:
This system combines continuous motion, sensing, and mechanical action. Focus on how these parts interact, not just how they work individually.