Potentiometer Challenge
- Audrey Schank

- Nov 4, 2024
- 3 min read
Our maker challenge with the Arduino for this week was to use the potentiometer to change the rate of a blinking LED. By using a variable resistor (potentiometer), we are able to control the rate of the blinking light.
I was initially a bit overwhelmed with all the wires and connections to make, but I followed the guide and was sure I had them all connected correctly. I had a bit of trouble getting the code correct and kept getting error messages. After triple checking it and making adjustments where I had missed a comma and a semicolon, I still couldn't get the LED to blink. I remembered something from last week about the positive and negative legs of the LED, so I took it out and turned it around, and thankfully my light started blinking! From there, I was able to turn the knob and control the rate of the blinking. I played around with it for a bit because I was thrilled that it finally worked!
Code for LED with Potentiometer
int sensorPin = 0;
int ledPin = 13;
void setup() {
// put your setup code here to run once:
pinMode (ledPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue;
sensorValue = analogRead (sensorPin);
digitalWrite(ledPin, HIGH);
delay (sensorValue);
digitalWrite(ledPin, LOW);
delay (sensorValue);
}
Video of Potentiometer: https://youtu.be/0TawDGqoNzo
Circuit and Code Play
See what happens if you use two digital pins rather than one digital and one analog pin.
Using 2 digital pins made the potentiometer stop working where the rate of blinking could no longer be controlled. The LED was just blinking like in the challenge from.week 1.
See what happens if you use two analog pins rather than one digital and one analog pin.
Using two analog pins caused the LED to turn off.
What happens if you replace the analogWrite with digitalWrite and vice versa?
Changing the code to analogWrite instead of digitalWrite didn't seem to change anything, but changing digitalWrite to analogWrite made the light turn off.

Extension Challenge
1. Can you control 2 lights with the same brightness or same blink rate?
I added a yellow LED to the breadboard and was able to control both lights with the same blink rate. The yellow light was much dimmer than the original red LED. I placed the yellow LED on the breadboard in F20, F21.
Video of Potentiometer with 2 LED's: https://youtu.be/_C024NrObNw
Reflection
While this week was challenging and I wanted to give up a couple of times, I didn't feel as overwhelmed as I did in week 1. I think being a bit familiar with the parts, wires, resistors, LED's, etc. was helpful. I followed the directions for setting up the breadboard exactly and only make the one mistake of putting the LED in backwards. I am struggling mostly with the coding at this point. It just doesn't make sense to me yet and is like reading a foreign language.
I think similar programs that can be found in the real world would likely include the dials that are used on walkie-talkies to adjust the volume and old thermostats that had a dial to adjust temperature before we had the digital and automatic ones we have today. Back in the old days, we also had TV's that you actually had to get up and walk over to in order to change the channel or adjust the volume using knobs. No remotes back then!


Comments