Bird
0
0
Arduinoprogramming~20 mins

DC motor with transistor driver in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DC Motor Driver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Arduino sketch controlling a DC motor speed?

Consider this Arduino code snippet that uses PWM to control a DC motor speed through a transistor driver. What will be the motor speed value printed on the serial monitor?

Arduino
const int motorPin = 9;
int speed = 128;

void setup() {
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  analogWrite(motorPin, speed);
  Serial.println(speed);
  delay(1000);
}
A64
B255
C128
D0
Attempts:
2 left
💡 Hint

Look at the value assigned to speed and what is printed.

🧠 Conceptual
intermediate
1:30remaining
Which component protects the transistor from voltage spikes when the motor stops?

In a DC motor driver circuit using a transistor, which component is essential to protect the transistor from voltage spikes generated by the motor's inductive load?

ACapacitor
BLED
CResistor
DFlyback diode
Attempts:
2 left
💡 Hint

Think about what happens when the motor suddenly stops and the transistor switches off.

🔧 Debug
advanced
2:30remaining
Why does this Arduino code fail to run the motor at full speed?

Analyze the following Arduino code intended to run a DC motor at full speed using a transistor driver. Identify the reason the motor does not run at full speed.

Arduino
const int motorPin = 9;

void setup() {
  pinMode(motorPin, OUTPUT);
}

void loop() {
  analogWrite(motorPin, 256);
  delay(1000);
}
APWM value 256 is invalid; max is 255
BPin 9 cannot output PWM
CMissing digitalWrite to turn motor on
DDelay is too short to see effect
Attempts:
2 left
💡 Hint

Check the valid range for PWM values in Arduino.

📝 Syntax
advanced
2:00remaining
Which option fixes the syntax error in this transistor driver control code?

Identify the correct syntax to set the transistor control pin as output and turn the motor on.

Arduino
int motorPin = 8

void setup() {
  pinMode(motorPin, OUTPUT)
  digitalWrite(motorPin, HIGH);
}
AAdd semicolons after variable declaration and pinMode line
BChange pinMode to pinmode and add semicolon after digitalWrite
CReplace int with const int and remove digitalWrite line
DAdd parentheses after motorPin declaration
Attempts:
2 left
💡 Hint

Look carefully at missing punctuation in Arduino C++ code.

🚀 Application
expert
1:30remaining
How many PWM steps are possible controlling the motor speed with analogWrite on Arduino?

Using analogWrite() on an Arduino to control a transistor-driven DC motor, how many distinct speed levels can you set?

A1024
B256
C128
D512
Attempts:
2 left
💡 Hint

Recall the resolution of Arduino's 8-bit PWM.