Inspiration
This week, I created a small motor system that can start, stop, and change its speed using Bluetooth from my phone 📱⚙️.
The idea came from the little toy cars I used to play with when I was younger — they could speed up, slow down, and zip around in different directions. I wanted to recreate that same sense of control and excitement, but this time build it myself from scratch. It’s like bringing a piece of my childhood into something I can engineer today.
Software
Tinkercad
I tested the buzzer loop game on Tinkercad Circuits by setting up the power, wires, and buzzer virtually. It let me see how the design works and fix mistakes safely before building it—like a quick rehearsal before the real thing.
Arduino IDE
I used the Arduino IDE as the main software tool for this assignment. The Arduino IDE is an integrated development environment designed specifically for programming and uploading code to Arduino boards. It provides a simple and user-friendly interface to write, compile, and debug code. It also includes a wide range of built-in libraries that make it easy to work with various sensors, modules, and electronic components. This made it an ideal choice for developing and testing the logic of my project efficiently.
Arduino BlueControl
I used Arduino BlueControl, a tool that lets you control an Arduino board wirelessly via Bluetooth. It allowed me to send commands from a mobile app to the Arduino, making it easy to control motors, LEDs, and other components in real time.
Electronic Components
Arduino UNO
Breadboard
Jumper Wires
RGB LED
Circuit Design
Wiring the Circuit
To wire the circuit, I followed these steps:
Power
Connected a 9V adapter to the L298N motor driver’s 12V and GND.
Connected Arduino GND to L298N GND for a common ground.
Powered Arduino via USB to avoid back-powering from the motor driver.
Motor Driver (L298N)
DC motor wires to OUT3 and OUT4.
IN3 → Arduino pin 4, IN4 → pin 3 (controls direction).
ENB → Arduino pin 11 (controls speed).
Bluetooth Module
TX → Arduino RX (pin 0), RX → Arduino TX (pin 1) through a voltage divider.
VCC → 5V, GND → GND.
RGB LED
Red → pin 8, Green → pin 9, Blue → pin 10 (all through 220Ω resistors).
Common cathode → GND.
Implementation Process
To implement my design, I first connected all the wires according to the planned circuit. After that, I ran several small unit tests using simple example codes to make sure each component was working correctly. Once I confirmed everything was functioning as expected, I uploaded my final code to the Arduino.
command → stores the letter sent from Serial (like S, R, +, -)
motorSpeed → current speed (0–255)
savedSpeed → remembers the last speed when stopped
isRunning → keeps track of whether the motor is running or stopped
Starts the Serial Monitor communication at 9600 baud.
Sets the motor and LED pins to OUTPUT mode (so Arduino can control them).
Calls stopMotor() to make sure the motor does not start spinning automatically.
When a character is received:
S (Stop) → remembers current speed, stops motor, turns LED off
R (Resume) → restarts motor at saved speed, updates LED color
+ (Increase) → raises speed by 50 (only if running)
- (Decrease) → lowers speed by 50 (only if running)
After any speed change, it calls runMotor() to apply the new speed and updateLED() to change the LED color.
runMotor(speed) → makes the motor spin forward at the given speed (0–255).
If speed is 0, it calls stopMotor().
stopMotor() → fully stops the motor by cutting power (ENB=0) and setting the direction pins low.
Changes the LED color based on the motor’s speed:
0 → off
1–100 → green
101–180 → blue
181–255 → red
The Code
Final Product
While building the project, I ran into an issue with the DC motor — it kept spinning nonstop as soon as the circuit was powered on, even when no commands were sent.
At first, the motor worked fine in unit tests, but when running the full code, it would just keep going. After some troubleshooting and research, I discovered the problem: the input pins (IN3 and IN4) were left floating at startup. This meant they could randomly be read as HIGH or LOW, which made the motor turn on by itself.
To fix this, I created an initial setup function that explicitly sets the motor pins LOW, fully stopping the motor when the system starts. Only after receiving commands would the motor turn on.
This taught me the importance of defining safe initial states for components before running the full code — something that can save a lot of confusion for anyone doing a similar assignment.