Adding a potentiometer to control motor speed.
For my input devices assignment, I added a small potentiometer from the starter kit. The potentiometer acts like a knob that the microcontroller can read as an analog input. I used it to control the speed of the cooling fan in my temperature-controlled system.
This assignment connected back to my earlier embedded programming work. The temperature sensor still tells the system when it is hot, but the potentiometer lets me manually control how fast the fan runs once cooling is needed.
The system worked similarly to the previous assignment. When I held the TMP36 temperature sensor, the temperature reading increased, the red LED turned on, and the motor started spinning.
As I turned the potentiometer knob, the fan speed increased or decreased. When the heat disappeared and the sensor cooled down, the green LED came back on and the motor shut off.
I did not get a chance to mill this exact PCB board yet because I was still working through the CNC software and internet connection issues from the previous week. I did complete the PCB design in KiCad. It was very similar to the Week 8 board, except I added a spot for the potentiometer input.
Before everything started working properly, I ran into an issue where the RP2350 board was not getting power correctly. After troubleshooting for a while, I realized the pins coming out of the microcontroller were not making a good connection on the breadboard.
After trying multiple things, I slightly pushed the board down and to the left, and suddenly the power came on. Once that happened, everything started working and I was back in business.
This taught me that sometimes the problem is not the code at all. A bad physical connection can make a good circuit act completely broken.
At first, I originally planned to use the Arduino Uno R3 for this assignment. However, I kept running into problems and eventually decided to switch over to the Seeed RP2350 instead.
The Arduino setup gave me several issues during testing. Later, I also discovered the RP2350 board pins were not making solid contact on the breadboard either. Once the RP2350 board powered correctly, the entire project started working normally again.
The potentiometer acted as the main input device for this assignment. The RP2350 reads the changing analog voltage from the potentiometer and uses that information to control the fan speed.
I learned how analog inputs work and how turning the potentiometer changes the analog value being read by the microcontroller. I also learned how to map those values into useful outputs like motor speed control.
This assignment helped me better understand how user input devices interact with embedded systems in real time.
The code below reads the potentiometer value and uses it to control the speed of the motor while also monitoring the temperature sensor.
int tempSensor = A0;
int potPin = A1;
int motorPin = 5;
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
int tempValue = analogRead(tempSensor);
int potValue = analogRead(potPin);
int motorSpeed = map(potValue, 0, 1023, 0, 255);
if(tempValue > 520) {
analogWrite(motorPin, motorSpeed);
} else {
analogWrite(motorPin, 0);
}
}
This code reads the potentiometer value and converts it into a PWM motor speed value. If the temperature rises above the threshold, the fan turns on and its speed is controlled by the potentiometer.
I also designed a PCB version of this project in KiCad. The PCB includes the RP2350 connections, potentiometer input, motor driver connections, and temperature sensor input.
The board was designed so the project could eventually move away from loose breadboard wiring and become a cleaner standalone system. Weeks 8, 9, and 10 all connect together because they are part of the same electronics learning path.
Hero shot of my board:
This assignment helped me understand how input devices can control system behavior in real time. I learned how a potentiometer can act as an analog input device and how the RP2350 can read changing values to adjust outputs like motor speed.
I also learned how important reliable electrical connections are. Even if the code is correct, a loose pin, bad breadboard connection, or weak contact can stop the whole project from working.