Challenge - 5 Problems
Stepper Motor Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Stepper Motor Basic Rotation Output
What will be the output behavior of the stepper motor when running this Arduino code snippet?
Arduino
const int stepPin = 3; const int dirPin = 4; void setup() { pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); digitalWrite(dirPin, HIGH); // Set direction } void loop() { digitalWrite(stepPin, HIGH); delayMicroseconds(1000); digitalWrite(stepPin, LOW); delayMicroseconds(1000); }
Attempts:
2 left
💡 Hint
Look at how the step pin is pulsed and the direction pin is set once in setup.
✗ Incorrect
The code sets the direction pin HIGH once, so the motor direction is fixed. The step pin is pulsed repeatedly with equal HIGH and LOW durations, causing continuous rotation in one direction.
🧠 Conceptual
intermediate1:00remaining
Understanding Stepper Motor Driver Pins
Which pin on a typical stepper motor driver module controls the rotation direction of the motor?
Attempts:
2 left
💡 Hint
Think about which pin tells the motor which way to turn.
✗ Incorrect
The direction pin controls the rotation direction by setting it HIGH or LOW. The step pin controls stepping pulses, enable pin turns the driver on/off, and ground is for electrical reference.
🔧 Debug
advanced2:00remaining
Identify the Error in Stepper Motor Speed Control Code
What error will occur when running this Arduino code to control stepper motor speed?
Arduino
const int stepPin = 3; const int dirPin = 4; void setup() { pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); digitalWrite(dirPin, LOW); } void loop() { for (int i = 0; i < 200; i++) { digitalWrite(stepPin, HIGH); delay(1); digitalWrite(stepPin, LOW); delay(1); } delay(1000); delay(0); }
Attempts:
2 left
💡 Hint
Check if delay(0) is valid and what setting direction LOW means.
✗ Incorrect
delay(0) is valid and just causes no delay. Direction LOW is a valid direction. The loop pulses the step pin 200 times with 1 ms delay each, rotating the motor 200 steps then pauses 1 second.
📝 Syntax
advanced1:30remaining
Find the Syntax Error in Stepper Motor Control Code
Which option contains the correct syntax to set the step pin HIGH and LOW with a 500 microsecond delay between?
Attempts:
2 left
💡 Hint
Check for missing commas, semicolons, and parentheses.
✗ Incorrect
Option A has correct syntax: commas separate arguments in digitalWrite, and semicolons terminate every statement. Option A misses semicolon after last delayMicroseconds(500). Option A misses commas after stepPin. Option A misses semicolons after each statement.
🚀 Application
expert2:00remaining
Calculate Steps for 90 Degree Rotation
A stepper motor has 200 steps per full revolution. Using a driver module, how many step pulses must be sent to rotate the motor shaft exactly 90 degrees?
Attempts:
2 left
💡 Hint
A full revolution is 360 degrees. Calculate the fraction for 90 degrees.
✗ Incorrect
90 degrees is one quarter of 360 degrees. One quarter of 200 steps is 50 steps.
