Challenge - 5 Problems
H-Bridge Motor Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the motor direction output?
Given the following Arduino code controlling an H-Bridge motor driver, what will be the motor direction output on pins IN1 and IN2?
Arduino
const int IN1 = 8; const int IN2 = 9; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); } void loop() { // Motor runs forward }
Attempts:
2 left
💡 Hint
Check the digitalWrite values in setup for IN1 and IN2.
✗ Incorrect
Setting IN1 HIGH and IN2 LOW causes the motor to rotate forward. The H-Bridge uses these signals to control motor direction.
❓ Predict Output
intermediate2:00remaining
What happens if both IN1 and IN2 are HIGH?
Consider this Arduino code snippet controlling an H-Bridge motor driver. What is the motor behavior when both IN1 and IN2 pins are set HIGH?
Arduino
const int IN1 = 8; const int IN2 = 9; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); digitalWrite(IN1, HIGH); digitalWrite(IN2, HIGH); } void loop() { // Motor brake }
Attempts:
2 left
💡 Hint
Both inputs HIGH usually activate braking in an H-Bridge.
✗ Incorrect
When both IN1 and IN2 are HIGH, the motor terminals are shorted internally causing braking effect.
🔧 Debug
advanced2:30remaining
Why does the motor not rotate forward?
This Arduino code is intended to rotate the motor forward using an H-Bridge, but the motor does not move. Identify the cause.
Arduino
const int IN1 = 8; const int IN2 = 9; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); } void loop() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); }
Attempts:
2 left
💡 Hint
Check the initial pin states in setup and how loop changes them.
✗ Incorrect
Setup sets both pins LOW initially, but loop sets IN1 HIGH and IN2 LOW repeatedly, so motor should run forward. However, if loop is not running or delayed, motor stays stopped. The main issue is that setup sets pins LOW and loop sets pins HIGH/LOW but loop runs continuously so motor should run. The problem is subtle: if loop is empty or not running, motor stays stopped. But here loop sets pins correctly. The best answer is that initial LOW in setup does not prevent motor running because loop sets pins HIGH/LOW. So the actual cause is that loop runs but motor does not move because wiring or power issue, but that is outside code. Among options, A is closest cause in code context.
📝 Syntax
advanced1:30remaining
Which code snippet correctly sets motor to rotate backward?
Choose the correct Arduino code snippet that sets the motor to rotate backward using an H-Bridge with pins IN1 and IN2.
Attempts:
2 left
💡 Hint
Backward rotation is the opposite of forward: IN1 LOW and IN2 HIGH.
✗ Incorrect
Setting IN1 LOW and IN2 HIGH reverses the motor direction in an H-Bridge.
🚀 Application
expert3:00remaining
How to implement motor stop with brake using Arduino and H-Bridge?
You want to stop the motor immediately with braking effect using an H-Bridge (L293D/L298N). Which Arduino code snippet correctly implements this braking?
Attempts:
2 left
💡 Hint
Braking is done by setting both inputs HIGH to short motor terminals.
✗ Incorrect
Setting both IN1 and IN2 HIGH causes the motor terminals to short internally, creating a braking effect.
