Week 7: Buzzer Motor
Project Overview
The goal of this project was to build a working circuit that could power and control a fan-blade DC motor using an Arduino. I set out to write code that would gradually increase and decrease the motor’s speed, demonstrating how PWM control works, but despite multiple rewires, code revisions, and constant troubleshooting, I couldn’t get the motor to respond at all. This experience turned into an unexpected challenge, but it helped me recognize the gaps in my understanding of motor circuits and showed me where I need to deepen my skills in debugging and hardware setup moving forward.
Code used:
// DC Fan Motor (No Controller) using NPN Transistor
// Arduino pin → transistor → motor
int motorPin = 9; // PWM pin connected to transistor base through 1k resistor
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
// Speed up the motor gradually
for (int speed = 0; speed <= 255; speed++) {
analogWrite(motorPin, speed);
delay(20);
}
delay(2000); // Run at full speed
// Slow it down
for (int speed = 255; speed >= 0; speed--) {
analogWrite(motorPin, speed);
delay(20);
}
delay(2000); // Pause before repeating
}